fork download
  1. /*******************************************************************************
  2.  * calculate BMI
  3. *_______________________________________________________________________________
  4. *Program calculates inputted BMI and displays whether input is overweight/optimal/underweight
  5. *_______________________________________________________________________________
  6. *INPUT
  7. *weight in pounds
  8. *height in inches
  9. *OUTPUT
  10. *BMI
  11. *******************************************************************************/
  12.  
  13. #include <iostream>
  14. #include <cmath>
  15. using namespace std;
  16.  
  17. int main( ) {
  18.  
  19. double weight;
  20. double height; //declare variables
  21. double BMI;
  22.  
  23. cout << "What is your weight in pounds?" << endl;
  24. cin >> weight;
  25. //get user input
  26. cout << "What is your height in inches?" << endl;
  27. cin >> height;
  28.  
  29. BMI =(weight*703) / pow(height, 2); //calculate BMI
  30.  
  31. cout << " " << endl << "your BMI is:" << BMI << endl; //display BMI
  32.  
  33. if (BMI < 18.6) {
  34. cout << "you are underweight."<< endl; }
  35. else if (BMI >= 18.5 && BMI <=25) {
  36. cout << "you are at an optimal weight" << endl; }
  37. else {
  38. cout << "you are overweight" << endl; }
  39.  
  40. return 0;
  41. }
Success #stdin #stdout 0.01s 5292KB
stdin
100
65
stdout
What is your weight in pounds?
What is your height in inches?
 
your BMI is:16.6391
you are underweight.