Advertisement
Sierra_ONE

Calculate the BMI

Oct 14th, 2023
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | Source Code | 0 0
  1. #include <stdio.h>
  2.  
  3. int main (void){
  4.    
  5.     float weight, height;
  6.    
  7.     printf("Enter the weight (pounds): ");
  8.     scanf("%f", &weight);
  9.     printf("Enter the height (inches): ");
  10.     scanf("%f", &height);
  11.    
  12.  
  13.     float BMI = 703 * (weight / (height * height));
  14.  
  15.    
  16.    
  17.    
  18.     if (BMI >= 18.5 && BMI <= 24.9){
  19.         printf("The BMI is %.1f (normal weight)", BMI);
  20.     }
  21.     else if (BMI >= 25 && BMI <= 29.9){
  22.         printf("The BMI is %.1f (overweight)", BMI);
  23.     }
  24.     else if (BMI < 18.5){
  25.         printf("The BMI is %.1f (underweight)", BMI);
  26.     }
  27.     else if (BMI > 30){
  28.         printf("The BMI is %.1f (obese)", BMI);
  29.     }
  30.    
  31.    
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement