Write a C language program to calculate the average of a series of number.
#include<stdio.h>
#include<conio.h>
void main()
{
int n, num[100],i;
float avg,sum=0;
printf("Enter how many no u want:");
scanf("%d",&n);
printf("Enter the %d Number: ",n);
for(i=0; i<n; i++)
{
scanf("%d",&num[i]);
sum=sum+num[i];
}
avg = sum/n;
printf("Average = %.2f",avg);
getch();
}
Input/Output:
Enter how many number u want: 4
Enter the 4 Number: 1 4 5 7
Average= 4.25
No comments
Dear Members, Thanks for Your Comments. We must be reply your comment answer as soon as possible. Please Stay with us.....