Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Creative Commons and Public Domain (use in any way you wish). (CC) Lauri Friberg 27th of June 2018.
- //Calculate the Body Mass Index (BMI) using height in meters (m) and weight in kilograms (kg).
- //The formula is BMI = weight (kg) / ((height (m))²) = weight(kg) / (height(m)*height(m)).
- #include <iostream>
- using namespace std;
- int main()
- {
- double BMI = 0, height = 0, weight = 0;
- cout << "Calculates the Body Mass Index (BMI) from height (m) and weight (kg).\n";
- cout << "Height (meters) = "; //Output to tell what to input.
- cin >> height; //Input height in meters (m).
- cout << "Weight (kg) = "; //Output to tell what to input.
- cin >> weight; //Input weight in kilograms (kg).
- BMI = weight / (height * height); //The BMI formula in simple mathematics.
- cout << "Body Mass Index = " << BMI << "\n"; //Output the Body Mass Index (BMI).
- return 0;
- }
Add Comment
Please, Sign In to add comment