Answer to Question #274816 in C for Amu Raj

Question #274816

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




input.

1
Expert's answer
2021-12-07T09:21:08-0500
#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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS