Thursday, 30 April 2020

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 aaray: ”);
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();
}

No comments:

Post a Comment