C Program to find average of the Arrays Elements
Write a C Program to find average of the Arrays Elements:
Required Knowledge:
C basics, ArraysProgram:
1 #include<stdio.h>
2 void main()
3 {
4 int n[5],i;
5 int average,sum;
6
7 for(i=0; i<=4; i++)
8 {
9 printf("Enter the number %d:",i+1);
10
11 scanf("%d",&n[i]);
12 }
13
14 sum=n[0];
15
16 for(i=1; i<=4; i++)
17 {
18 sum=sum+n[i];
19
20 average=sum/n[i];
21 }
22 printf("average is:%d",average);
23 }
Comments
Post a Comment
Dears! Yours Comment approved in 24 hours also your answer in 24 hours.......