Question

when i run this, it ends after user input of weight and height, what am i...

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

Homework Answers

Answer #1
#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

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
#include <stdio.h> int main( void ) {     double height, weight, bmi;     int bmievalcode;    ...
#include <stdio.h> int main( void ) {     double height, weight, bmi;     int bmievalcode;     while( 1 )     {         /* --> add code to input weight and height between here */         scanf("%lf %lf\n" , &weight &height)         bmi = weight * 703 / (height * height);         /* <-- and here */         /* --> add code to calculate bmi and bmievalcode between here */         if (bmi <= 00.0){             bmievalcode = -1;         else...
why's is my csis.txt saving ? #include <stdio.h> FILE*fp; void calculateBMI(void); int main(void) {    fp...
why's is my csis.txt saving ? #include <stdio.h> FILE*fp; void calculateBMI(void); int main(void) {    fp = fopen("csis.txt", "w"); for (int i= 0; i<4; ++i){ calculateBMI(); } fclose(fp); return 0; } void calculateBMI(void){ double weight,height,bmi;    printf("Enetr your weight in pounds:\n\n"); fprintf(fp,"Enter your weight in pounds:\n\n"); scanf("%lf",&weight); printf("Enter height in inches:\n\n"); fprintf(fp,"Enter height in inches:\n\n"); scanf("%lf",&height); bmi=(703*weight)/(height*height);    if (bmi<18.5){ printf("You have a BMI of %.lf, and your weight status is underweight\n",bmi);    fprintf(fp,"You have a BMI of %.lf, and...
I need to add two trivial functions to the following code. I am having an issue...
I need to add two trivial functions to the following code. I am having an issue with what i may need to change in the current code to meet the requirements. I am already displaying the bank record but now using a function Here are some examples of what i can add to the code 1. Obtain opening (current) balance. 2. Obtain number the number of deposits. 3. Obtain number of withdrawals. 4. Obtain deposit amounts. 5. Obtain withdrawal amounts....
No matter what I do I cannot get this code to compile. I am using Visual...
No matter what I do I cannot get this code to compile. I am using Visual Studio 2015. Please help me because I must be doing something wrong. Here is the code just get it to compile please. Please provide a screenshot of the compiled code because I keep getting responses with just code and it still has errors when I copy it into VS 2015: #include <iostream> #include <conio.h> #include <stdio.h> #include <vector> using namespace std; class addressbook {...
For a C program hangman game: Create the function int setup_game [int setup_game ( Game *g,...
For a C program hangman game: Create the function int setup_game [int setup_game ( Game *g, char wordlist[][MAX_WORD_LENGTH], int numwords)] for a C program hangman game. (The existing code for other functions and the program is below, along with what the function needs to do) What int setup_game needs to do setup_game() does exactly what the name suggests. It sets up a new game of hangman. This means that it picks a random word from the supplied wordlist array and...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT