Find the average height of 10 students
C program to find the average of height of 10 students.
Program
#include<stdio.h>
#include<conio.h>
void main()
{
int arr[10];
int i, n, sum;
float avg;
printf("Enter the height of 10 students in centimetres\n");
for(i=0;i<10;i++)
{
printf("Height of student %d\t:",i+1);
scanf("%d",&arr[i]);
}
sum = 0;
for(i=0;i<10;i++)
{
sum = sum + arr[i];
}
avg = sum / 10;
printf("\nAverage of the height of the students is\t:%f",avg);
getch();
}
Output
Enter the height of 10 students in centimetres
Height of student 1 :125
Height of student 2 :142
Height of student 3 :128
Height of student 4 :137
Height of student 5 :136
Height of student 6 :129
Height of student 7 :150
Height of student 8 :149
Height of student 9 :135
Height of student 10 :139
Average of the height of the students is :137.000000