Given 'N' elements, find the sum and average of 'N' elements and print them.
Implementation:
Implementation:
#include <stdio.h>
#include <stdlib.h>
/* Array Size */
#define MAX 100000
int main(void) {
/* Sum is initialized to 0 to get rid of garbage values getting intialized*/
int a[MAX],i,n,sum=0,average;
/* Get the number of elements of the array */
scanf("%d",&n);
/* Get the elements of the array */
for(i=0;i<n;i++)
{
scanf("%d",(a+i));
/* Calculate the sum of the elements of the array while getting input from the user */
sum+=*(a+i);
}
/* Calculate the average of the array */
average=sum/n;
printf("sum of elements is %d",sum);
printf("average of elements is %d",average);
return 0;
}