C program to accept marks of 10 students and display total marks,average marks, maximum and minimum marks

Example#1

#include<stdio.h>
int main()
{
	int n,i,a[30],total=0,max,min;
	float avg;
	printf("Enter the size of array:");
	scanf("%d",&n);
	printf("Enter marks of 10 students:");
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
		max=min=a[0];
	printf("Marks are:");
	for(i=0;i<n;i++)
	{
		printf("%d ",a[i]);
	}
	for(i=0;i<n;i++)
	{
	
		if(a[i]>max)
		max=a[i];
		if(a[i]<min)
		min=a[i];
	}
	for(i=0;i<n;i++)
	{
		total=total+a[i];
	}
	avg=(float)total/n;
	printf("\nMaximum marks:%d",max);
	printf("\nMinimum marks:%d",min);
	printf("\nTotal marks:%d",total);
	printf("\nAverage marks:%.2f",avg);
	return 0;
}

Output:

Facebook Comments

Back to Top