C Program to Calculate Average height of persons

Sreemeenakshi V
2 min readJun 10, 2021

--

Language Used: C

Concepts Involved:

For Loop

Syntax:

for (Statement; testExpression; updateStatement)
{
// statements
}

Flowchart:

C if Statement:

Syntax:

if (test expression) 
{
statement(s)
}
  • If the test expression is evaluated to true, statements inside the body of if are executed.
  • If the test expression is evaluated to false, statements inside the body of if are not executed.

How it works?

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:

Output:

Enter the Number of Persons : 5 
Enter the Height of each person in centimeter
179
174
177
167
181
Average Height of 5 persons is : 175.60
The number of persons above average : 3

Description:

Here, the average value is declared as a float value as the resultant value can be a decimal number.

Using scanf function the input information regarding the number of persons is read.

Using for loop and scanf function, the height of each person is checked, read and is printed using printf function.

If height is greater than average then the count is increased and the final count is displayed stating the number of persons above average height.

For any Educational Assistance,

Refer: https://www.guvi.in/

--

--

No responses yet