SHOW SUM OF TEN ELEMENTS OF ARRAY AND TO FIND THEIR AVERAGE

/*PROGRAM TO SHOW SUM OF TEN ELEMENTS OF ARRAY AND TO FIND THEIR AVERAGE*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,a[10],sum=0;
float avg;
clrscr();
printf(“Enter ten elements in an array: \n”);
for(i=0;i<10;i++)
scanf(“%d”,&a[i]);
printf(“\nEntered elements are:\n”);
for(i=0;i<10;i++)
{
printf(“%d\n”,a[i]);
sum=sum+a[i];
}
printf(“\nSum of given elements is: %d”,sum);
avg=sum/10.0;
printf(“\nAverage of these elements is: %.2f”,avg);
getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *