I am doing a relatively simple program to calculate a length * width * height into cubic inches. I am supposed to get an answer like XXXXXXX.XX
but instead the compiler gives me 0.000000
I have no other errors. My main question is how to get the numbers to calculate?
#include <stdio.h>
double length;
double width;
double height;
// This is the volume in cubic inches.
double VolumeCubicInch;
// This is the volume in cubic feet.
double VolumeCubicFeet;
int main() {
// Ask the user to enter the length width and height of a box (in inches).
// First print asks user to enter the length of a box in inches.
printf("Please enter the length of a box in inches.\n");
// The user reads in the length number of the box in inches.
scanf("%lf", &length);
// Second print asks user for the width of the box in inches.
printf("Now please enter the width of the box in inches.\n");
// The user reads in the width number in inches.
scanf("%lf", &width);
// Then the third print asks user for the height of the box in inches.
printf("Please enter the height of box in inches.\n");
// The user reads in the height of the box in inches.
scanf("%lf", &height);
// Calculate the volume of the box, in cubic inches and output the result.
// Using a newly created variable called VolumeCubicInch, it will allow the calculation
// of the box's volume to be calculated in cubic inches.
// Length output given: 15.8
// Width output given: 23.34
// Height output given: 75.345
VolumeCubicInch = length * width * height;
// The resulted volume in cubic inches will be outputted using a print statement.
// Output should be: The volume is XXXXXXX.XX cubic inches.
printf("The volume is %lf cubic inches.\n", &VolumeCubicInch);
// Calculate the volume in cubic feet, and output the result.
// Using the variable VolumeCubicFeet will produce the volume in cubic feet.
// VolumeCubicFeet = ;
// The value or result of the volume in cubic feet will be outputted using the variable VolumeCubicFeet.
// The output should be: The volume is XXXX.XX cubic feet.
// printf("The volume is %lf cubic feet.\n", &VolumeCubicFeet);
// Note that a box that is 12 x 12 x 12 inches is 1.0 cubic feet.
// *Be sure that your program gets that answer.*
system("PAUSE");
return 0;
}