Search (Article Or Program)

18 June 2011

Using array the average height of students

//*Height of Student*//
#include
#include
main()
{
float hgt[30];
int n,stdn;
float sum=0;
clrscr();
gotoxy(15,5);
printf("Using array the average height of students \n\n\n");
printf("Enter how many : ");
scanf("%d",&n);
for(stdn=1;stdn<=n;stdn++)
{
printf("\nEnter height of student %d :",stdn);
scanf("%f",&hgt[stdn]);
}
for(stdn=1;stdn<=n;stdn++)
{
sum+=hgt[stdn];
}
printf("\n\n\n\nThe average is %f",sum/n);
getche();
}