C Program to Find Average of Array

C Program:

/* C program to accept n integers in array and calculate average of all integers

#include<stdio.h>

void main()
{
 int arr[100],size,sum=0;

 printf("\n Enter size of array:- ");
 scanf("%d",&size);

 printf("\n Enter array elements:- ");

 for(i=0;i<size;i++)
 {
 scanf("%d",&arr[i]);
 
 sum=sum+arr[i];
 }
 
 printf("\n Average of all integers of array is %d",sum/size);


}
Output of Above Code:

 Enter size of array:- 10
                                                                                                                    
 Enter array elements:- 10 11 2 5 8 7 9 9 10 14
                                                                            
 Average of all integers of array is 8


Comments