Tuesday, September 7, 2010

Average of n numbers

#include
#include
void main(
{
 float avg,sum=0;
 int i,n,a;

 printf("Enter n no. values: ");
 scanf("%d",&n);
 printf("\nEnter marks");

 for(i=1;i<=n;i++)
 {
  scanf("%d",&a);
  sum=sum+a;
 }

 avg=sum/n;
 printf("\naverage marks=%.1f",avg);
 getch();

}

No comments: