Programming Examples
C program to input 10 number in array and find its sum and average
Write a C program to input 10 integer number in array and find its sum and average.
Solution
#include<stdio.h>
int main()
{
int a[10],i,x,sum=0;
float avg;
printf("\nEnter the 10 element\n");
for(i=1;i<=10;i++)
{
scanf("%d",&a[x]);
sum=sum+a[x];
}
avg=(float)sum/10;
printf("sum=%d\n average=%f",sum,avg);
return 0;
}
Output
Enter the 10 element
3
4
5
5
6
6
4
3
3
2
sum=41
average=4.100000