Question #274816

Write a C Program to calculate the Average of an array elements where the elements are received as




input.

Expert's answer

#include<stdio.h>
int main(){
	int n;
	printf("Enter the number of elements:  ");
	scanf("%d", &n);
	printf("Enter %d elements of the array\n", n);
	int i;
	int arr[n];
	int sum = 0;
	for(i=0; i<n; i++){
		scanf("%d", &arr[i]);
		sum += arr[i];
	}
	printf("The average is:  %d", (sum/n));
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS