#include<stdio.h>
main ()
{
int a[50],i,n,sum=0;
float avg;
printf("Enter the no.of elements\t");
scanf("%d",&n);
printf("\nEnter the elements\t");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
sum=sum+a[i];
}
avg=(float)sum/(float)n;
printf("Average of given %d elements in the array is %f",n,avg);
getch();
}
main ()
{
int a[50],i,n,sum=0;
float avg;
printf("Enter the no.of elements\t");
scanf("%d",&n);
printf("\nEnter the elements\t");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
sum=sum+a[i];
}
avg=(float)sum/(float)n;
printf("Average of given %d elements in the array is %f",n,avg);
getch();
}
![]() |
| output |

No comments:
Post a Comment