C PROGRAM TO FIND THE BODY MASS OF THE INDIVIDUALS

 ALGORITHM:

    1. Start 

    2. Declare variables 

    3. Read the number of persons and their height and weight. 

    4. Calculate BMI=W/H 2 for each person 

    5. Display the output of the BMI for each person. 

    6. Stop

PROGRAM:

#include<stdio.h>
#include<math.h>
int main(void){
int n,i,j;
printf("How many people's BMI do you want to calculate?\n");
scanf("%d",&n);
float massheight[n][2];
float bmi[n];
for(i=0;i<n;i++){
 for(j=0;j<2;j++){
 switch(j){
 case 0:
 printf("\nPlease enter the mass of the person %d in kg: ",i+1);
 scanf("%f",&massheight[i][0]);
 break;
case 1:
 printf("\nPlease enter the height of the person %d in meter: ",i+1);
 scanf("%f",&massheight[i][1]);
 break;}
 }
}
for(i=0;i<n;i++){
 bmi[i]=massheight[i][0]/pow(massheight[i][1],2.0);
 printf("Person %d's BMI is %f\n",i+1,bmi[i]);
}
return 0;
}


OUTPUT:

How many people's BMI do you want to calculate?
2
Please enter the mass of the person 1 in kg: 88
Please enter the height of the person 1 in meter: 1.8288
Please enter the mass of the person 2 in kg:58
Please enter the height of the person 2 in meter: 2.2
Person 1's BMI is 26.31178
Person 2's BMI is 11.98347

Leave a comment