# Array Operation: Person above average height

#### Program 7: person above average height

##### Intro Text

This exercise can be considered as the real life example. Where you get number of peoples height and calculate the average height of person. With a simple comparison between peoples average height and height of individuals, we can find the number of peoples above average height. That’s all.

##### Programming Procedure
###### Get Peoples height

we need to declare an array of size 100. Here 100 is considered as the maximum. First we need to get the number of persons using a simple scanf statement. Then using a or loop we will get the height of each persons. here is he code snippet for that.

```printf("\nEnter number of persons...");
scanf("%d",&n);
for(i=0;i<n;i++){
person[i]=0.0f;
}
printf("\nEnter the height for each person");
for(i=0;i<n;i++){
printf("\nEnter the height for person%d...",i+1);
scanf("%f",&person[i]);
}```

###### Finding the average

We will find the average height of person is by summing up the height of individual person then divided by the total number of person.

`avg height = (sum of individual weight / no. of person)`
###### People above average height

we can find the people above average height by comparing the average height with height of individuals. If the height of the person is above average height the we will add 1 to count.

##### Program Code

The final program for finding people above average height is….

``` /*
Experiment:
1.Get number of persons
2.Get height for each person
3.take avg height
4.display person whose height is more than avg
*/
#include<stdio.h>
#include<conio.h>
#define MAX 100

void main(){
int i,n=0,noOfPerson=0;
float person[MAX],avg=0.0f,sum=0.0f;
clrscr();
printf("\nPEOPLE WHOES HEIGHT ABOVE AVG");
printf("\n*****************************");
printf("\nEnter number of persons...");
scanf("%d",&n);
for(i=0;i<n;i++){
person[i]=0.0f;
}
printf("\nEnter the height for each person");
for(i=0;i<n;i++){
printf("\nEnter the height for person%d...",i+1);
scanf("%f",&person[i]);
}
for(i=0;i<n;i++){
sum +=person[i];
}
avg = sum/n;
printf("Average Height is...%f",avg);
for(i=0;i<n;i++){
if(person[i]>avg){
noOfPerson+=1;
}
}
printf("\nNo. of Person above average...%d",noOfPerson);
getch();
}```