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