cpp_primer_plus/ch03/02.cpp
2022-08-23 23:01:08 +01:00

26 lines
594 B
C++

# include <iostream>
# include <cmath>
using namespace std;
int ic2ft = 12; // 1 inch = 12 feet
double ft2m = 0.0254; // 1 feet = 0.0254 meter
float kg2p = 2.2;
double bmi (double a, double b);
int main(){
double inch, feet;
double pound;
cout << "Enter Your Height (Inch feet): ";
cin >> inch >> feet;
double meter = (inch * ic2ft + feet) * ft2m;
cout << "Enter Your Weight (pound): ";
cin >> pound;
double kg = pound / kg2p;
double c = bmi (kg, meter);
cout << "The BIM is " << c << endl;
return 0;
}
double bmi (double a, double b){
double c = 1 / pow(b,2) * a;
return c;
}