### " C program " Adding Questions and using Answeres in Calculations

I am trying to do a BMI calculator.

My code below asks for weight and height below and then returns the BMI result with the definition of your weight status.

I would like to be able to do the following

2. How Old are you?
3. How much do you weigh in Kg's?
4. What is your height in Meters

Then from the code it takes this information and calculates the BMI and returns

"xyz you are 25 years old your BMI is (result of the calculation your status is (what ever corresponds to that result.

I would be most grateful if I can be pointed in the right direction to do this.

Many thanks

Rodney

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143`` `````` #include enum { black, dark_blue, dark_green, dark_cyan, dark_red, dark_magenta, dark_yellow, light_gray, dark_gray, light_blue, light_green, light_cyan, light_red, light_magenta, light_yellow, white }; int getcolors() { CONSOLE_SCREEN_BUFFER_INFO csbi; GetConsoleScreenBufferInfo( GetStdHandle( STD_OUTPUT_HANDLE ), &csbi ); return csbi.wAttributes; } int getfgcolor() { return getcolors() & 0x0F; } int getbgcolor() { return getcolors() >> 4; } void setfgcolor( int color ) { SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), (getcolors() & 0xF0) | (color & 0x0F) ); } void setbgcolor( int color ) { SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), ((color & 0x0F) << 4) | (getcolors() & 0x0F) ); } void setcolors( int fg, int bg ) { SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), ((bg & 0x0F) << 4) | (fg & 0x0F) ); } #include #include #include #include #include int main() { float height, weight,bmi; setfgcolor( black ); setbgcolor( light_magenta ); printf("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n"); printf("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n"); printf("xx xx\n"); printf("xx xx\n"); printf("xx Body Mass Index (BMI) is a number calculated from a person's weight xx\n"); printf("xx and height. BMI provides a reliable indicator of body fatness for xx\n"); printf("xx most people and is used to screen for weight categories that may xx\n"); printf("xx lead to health problems. xx\n"); printf("xx xx\n"); printf("xx xx\n"); printf("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n"); printf("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n"); printf("\n"); printf("\n"); Sleep(6000); system("cls"); printf("\n"); setbgcolor( white ); setbgcolor( light_green ); printf("Enter Weight in Kg's and Height in METERS \n"); scanf("%f%f", &weight, &height ); bmi = weight/(height*height); system("cls"); printf(" Your BMI is %.2f\n ",bmi); if(bmi<=18.5) { printf("you are under weight\n"); } else if(bmi<=25){ printf("your weight is normal\n"); } else if(bmi<=50){ printf("you are over weight\n"); } else if(bmi<=200){ printf("you are obese\n"); } return(0); }``````
Your program compiles and seems to execute.

Note. Your program will exit immediately after displaying the result.
http://www.cplusplus.com/forum/beginner/1988/
My question is

My code asks for weight and height below and then returns the BMI result with the definition of your weight status.

I would like to be able to do the following from the below questions

2. How Old are you?