ALGORITHM:
1. Start
2. Declare variables
3. Read the total number of persons and their height.
4. Calculate avg=sum/n and find number of persons their h>avg.
5. Display the output of the calculations .
6. Stop
PROGRAM:
#include <stdio.h>
#include <conio.h>
void main()
{
int i,n,sum=0,count=0,height[100];
float avg;
//Read Number of persons
printf("Enter the Number of Persons : ");
scanf("%d",&n);
//Read the height of n persons
printf("\nEnter the Height of each person in centimeter\n");
for(i=0;i<n;i++)
{
scanf("%d",&height[i]);
sum = sum + height[i];
}
avg = (float)sum/n;
//Counting
for(i=0;i<n;i++)
if(height[i]>avg)
count++;
//display
printf("\nAverage Height of %d persons is : %.2f\n",n,avg);
printf("\nThe number of persons above average : %d ",count);
getch();
}
Ouput:
Enter the Number of Persons : 5
Enter the Height of each person in centimeter
150
155
162
158
154
Average Height of 5 persons is : 155.8
The number of persons above average : 2