recent

Program to show sum of 10 elements of array & show the average

Write a Program to show sum of 10 elements of array & show the average:-

#include<stdio.h>
void main()
{
int a[10],i,sum=0;
float average;

printf("enter elements of an array: \n");
for(i=0;i<10;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<10;i++)
{
sum=sum+a[i];
}

printf("sum=%d",sum);
average=sum/10;
printf("average=%.2f",average);
}
Powered by Blogger.