Write a C program to compute the average age of nth student
Expert Answer
Source code:
#include<stdio.h>
int main()
{
int i,n,Sum=0,numb;
float Avg;
printf(“nPlease Enter total number of numbers n”);
scanf(“%d”,&n);
printf(“nPlease Enter the age one after one n”);
for(i=0;i<n;++i)
{
scanf(“%d”,&numb);
Sum = Sum +numb;
}
Avg = Sum/n;
printf(“nAverage age of the %d Numbers = %.2f”,n, Avg);
return 0;
}
Output screenshot: