Skip to content

Instantly share code, notes, and snippets.

@edenizk
Created May 11, 2018 16:56
Show Gist options
  • Select an option

  • Save edenizk/741a58cced03bf08568b24dd85e6724f to your computer and use it in GitHub Desktop.

Select an option

Save edenizk/741a58cced03bf08568b24dd85e6724f to your computer and use it in GitHub Desktop.
BMI calculator
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
double bmi,w,h;
cout<<"Welcome to BMI(body mass index) calculator\n for start please write your weight[kilogram]:";
cin>>w;
cout<<"write your height[meter]:";
cin>>h;
if (h>100){
h=h/100;
}
bmi=w/(h*h);
if(bmi<=18.5){
cout<<"your BMI is: "<<bmi<<"\n you are underweight";
}
else if(bmi>18.5&&bmi<=25){
cout<<"your BMI is: "<<bmi<<"\n you are healthy :)";
}
else if(bmi>25&&30>=bmi){
cout<<"your BMI is: "<<bmi<<"\n you are overweight";
}
else if(bmi<=40&&bmi>30){
cout<<"your BMI is: "<<bmi<<"\n you are obese";
}
else if(bmi>40){
cout<<"your BMI is: "<<bmi<<"\n you are extremely obese you need to do something!!";
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment