Below is the program in the C programming language to find the average of all the elements of the array –
/* C program to find the average of the elements of the array */ #include<stdio.h> #include<conio.h> void main() { int ar[100],n,i,sum=0; float avg; printf("Enter the size of the array \n"); scanf("%d",&n); printf("Enter the elements of the array to find their average \n"); for(i=0;i<n;i++) { scanf("%d",&ar[i]); sum=sum+ar[i]; } avg=(float)sum/n; printf(" Average is %f",avg); getch(); }
Thanks for giving the c programs on website,by this we clear my doubts
thanks ,it is the simplest and successfully running one