when i run this, it ends after user input of weight and height, what am i doing wrong?
#include <stdio.h>
#include <stdlib.h>
//function main begins program execution
int main ()
{
float weightCal = 0.0; // weight of the person
float heightCal = 0.0; // height of the person
float bmiCal = 0.0; // user's BMI
// get user's height
printf("Please enter your height (in inches):");
scanf( "%f", &heightCal);
// get user's weight
printf("Please enter your weight (in pounds): " );
scanf( "%f", weightCal );
bmiCal = weightCal * 703 / ( heightCal * heightCal ); // calculate BMI
printf( "\nYour BMI is %.1f.\n\n", bmiCal ); // output BMI to one floating point value
// output data to user
puts( "** BMI VALUES **********************************" );
puts( "**\t\t\t\t\t\t**" );
puts( "**\tUnderweight:\tless than 18.5\t\t**" );
puts( "**\tNormal:\t\tbetween 18.5 and 24.9\t**" );
puts( "**\tOverweight:\tbetween 25 and 29.9\t**" );
puts( "**\tObese:\t\t30 or greater\t\t**" );
puts( "**************************************************\n"
);
system ("pause");
return 0;
} // end main
#include <stdio.h> #include <stdlib.h> //function main begins program execution int main () { float weightCal = 0.0; // weight of the person float heightCal = 0.0; // height of the person float bmiCal = 0.0; // user's BMI // get user's height printf("Please enter your height (in inches):"); scanf( "%f", &heightCal); // get user's weight printf("Please enter your weight (in pounds): " ); scanf( "%f", &weightCal ); bmiCal = weightCal * 703 / ( heightCal * heightCal ); // calculate BMI printf( "\nYour BMI is %.1f.\n\n", bmiCal ); // output BMI to one floating point value // output data to user puts( "** BMI VALUES **********************************" ); puts( "**\t\t\t\t\t\t**" ); puts( "**\tUnderweight:\tless than 18.5\t\t**" ); puts( "**\tNormal:\t\tbetween 18.5 and 24.9\t**" ); puts( "**\tOverweight:\tbetween 25 and 29.9\t**" ); puts( "**\tObese:\t\t30 or greater\t\t**" ); puts( "**************************************************\n" ); system ("pause"); return 0; } // end main
Note: You missed & before weightCal
Get Answers For Free
Most questions answered within 1 hours.