Body Mass Index (BMI) is a measure of health on weight. It can be calculated by taking your weight in kilograms and dividing by the square of your height in meters. Write a program that prompts the user to enter a weight in pounds and height in inches and displays the BMI.
weight. It can be calculated by taking your weight in kilograms and dividing by the
square of your height in meters. Write a program that prompts the user to enter a
weight in pounds and height in inches and displays the BMI. Note that one pound is
0.45359237 kilograms and one inch is 0.0254 meters.
#Beginner
In gcc c++ compiler using namespace std;
#include<iostream>
using namespace std;
int main()
{
const float KG_PER_POUND=0.45359237;
const float METER_PER_INCH=0.0254;
float pound,inch;
cout<<"Enter weigth in pounds :";
cin>>pound;
cout<<"Enter heigth in inces :";
cin>>inch;
float bmi=(float)(pound*KG_PER_POUND)/((inch*METER_PER_INCH)*(inch*METER_PER_INCH));
cout<<"BMI is "<<bmi;
return 0;
}
Output
Enter weigth in pounds :95.5
Enter heigth in inces :50
BMI is 26.8573
[Program finished]
Best Sellers in Computers & Accessories
Comments
Post a Comment
Any doubt about programming or questions