In this tutorial, we are going to write a C Program to show the sum of 10 elements of array & show the average in C Programming with practical program code and step-by-step full complete explanation.
C Program to show sum and average of 10 elements of the array.
#include<stdio.h> #include<conio.h> void main() { int a[10],i,sum=0; float av; clrscr(); printf("Enter elements of an array: "); for(i=0;i<10;i++) { scanf("%d",&a[i]); } for(i=0;i<10;i++) { sum=sum+a[i]; } printf("sum=%d",sum); av=sum/10; printf("average=%.2f",av); getch(); }
Output
Enter elements of an array: 4 5 6 1 2 3 5 5 4 7 sum=42 average=4.22