LauriFriberg

Calculate the Body Mass Index (BMI) using height and weight

Jun 27th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. //Creative Commons and Public Domain (use in any way you wish). (CC) Lauri Friberg 27th of June 2018.
  2. //Calculate the Body Mass Index (BMI) using height in meters (m) and weight in kilograms (kg).
  3. //The formula is BMI = weight (kg) / ((height (m))²) = weight(kg) / (height(m)*height(m)).
  4. #include <iostream>
  5. using namespace std;
  6. int main()
  7. {
  8. double BMI = 0, height = 0, weight = 0;
  9. cout << "Calculates the Body Mass Index (BMI) from height (m) and weight (kg).\n";
  10. cout << "Height (meters) = ";   //Output to tell what to input.
  11. cin >> height;                  //Input height in meters (m).
  12. cout << "Weight (kg) = ";       //Output to tell what to input.
  13. cin >> weight;                  //Input weight in kilograms (kg).
  14. BMI = weight / (height * height); //The BMI formula in simple mathematics.
  15. cout << "Body Mass Index = " << BMI << "\n"; //Output the Body Mass Index (BMI).
  16. return 0;
  17. }
Add Comment
Please, Sign In to add comment