Sum and average of 10 numbers
C program to read 10 numbers from the keyboard and find their sum and average.
Program
#include<stdio.h>
#include<conio.h>
void main()
{
int i, num, sum = 0;
float avg;
printf("Enter 10 numbers\n");
for(i=1;i<=10;i++)
{
printf("Number - %d\t:",i);
scanf("%d",&num);
sum = sum + num;
}
avg = sum/10;
printf("\nSum = %d",sum);
printf("\nAverage = %f",avg);
getch();
}
Output
Enter 10 numbers
Number - 1 :5
Number - 2 :6
Number - 3 :7
Number - 4 :78
Number - 5 :45
Number - 6 :12
Number - 7 :54
Number - 8 :65
Number - 9 :56
Number - 10 :87
Sum = 415
Average = 41.000000