C program to input 10 number in array and find its sum and average

Programming Example

Write a C program to input 10 integer number in array and find its sum and average.

Solution

#include<stdio.h>
int main()
{
	int a[10],i,x,sum=0;
	float avg;
	printf("\nEnter the 10 element\n");
	for(i=1;i<=10;i++)
	{
		scanf("%d",&a[x]);
		sum=sum+a[x];
	}
	avg=(float)sum/10;
	printf("sum=%d\n average=%f",sum,avg);
	return 0;
}
Output

Enter the 10 element

3

4

5

5

6

6

4

3

3

2

sum=41

average=4.100000

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Website development Company in Allahabad