/* Average Of N Numbers */
#include < stdio.h >
#include < conio.h >
void main()
{
float
a[20],sum,avg;
int
n,i;
clrscr();
printf("\nEnter
n : ");
scanf("%d",
&n);
printf("\nEnter
%d numbers \n",n);
for(i=0;i
< n;i++)
{
scanf("%f", &a[i]);
}
sum =
0;
for(i=0;i
< n;i++)
{
sum
+= a[i];
}
avg =
sum / n;
printf("\nEntered
%d numbers are \n",n);
for(i=0;i
< n;i++)
{
printf("\n%.2f",a[i]);
}
printf("\nThe
average of numbers is %f",avg);
}
No comments:
Post a Comment