C program to show sum of 10 elements of array & show the average

				
					#include<stdio.h> 
#include<conio.h>
void main()
{
int a[10],i,sum=0;
float av;
clrscr();
printf(“enter elements of an array: ”);
for(i=0;i<10;i++)
scanf(“%d”,&a[i]);
for(i=0;i<10;i++) 
sum=sum+a[i]; 
printf(“sum=%d”,sum); 
av=sum/10; 
printf(“average=%.2f”,av);
getch();

}

				
			
Output: 
enter elements of an array: 4 5
6
1
2
3
5
5
4
7
sum=42
average=4.22

*************************

Leave a Reply