So I'm a total newb to C. I'm using eclipse with MinGW compiler. I'm on the second chapter using the scanf and printf functions and my program is working, but only printing the statements to the console once I've entered the three ints into the scanf functions.
#include <stdio.h>
int main(void){
int length, height, width, volume, dweight;
printf("Enter the box length: ");
scanf("%d", &length);
printf("\nEnter the box width: ");
scanf("%d", &width);
printf("\nEnter the box height");
scanf("%d", &height);
volume = length * width * height;
dweight = (volume + 165) / 166;
printf("Dimensions: l = %d, w = %d, h = %d\n", length, width, height);
printf("Volume: %d\n", volume);
printf("Dimensional Width: %d\n", dweight);
return 0;
}
console output:
8 (user input + "Enter" + key)
10 (user input + "Enter" key)
12 (user input + "Enter" key)
Enter the box length:
Enter the box width:
Enter the box heightDimensions: l = 8, w = 10, h = 12
Volume: 960
Dimensional Width: 6
any insights? I'm expecting it to printf, then scanf for user input like so:
Enter the box length: (waits for user int input; ex. 8 + "Enter")
Enter the box width: ...