I'm trying to execute a program from the book by K. N. King "C Programming, A Modern Approach, 2 Edition", in NetBeans 8.0.2, using MinGW compiler. The program looks like this:
#include <stdio.h>
int main(void) {
int height, length, width, volume, weight;
printf("Enter height of box: ");
scanf("%d", &height);
printf("Enter length of box: ");
scanf("%d", &length);
printf("Enter width of box: ");
scanf("%d", &width);
volume = height * length * width;
weight = (volume + 165) / 166;
printf("Volume (cubic inches): %d\n", volume);
printf("Dimensional weight (pounds): %d\n", weight);
return 0;
}
So, I press "Run Project", the program builds successfully without any errors, then it begins to run and nothing happens, no console or something like that appears to input data like height, length, etc.
In the output window, after the program builded, it begins to run and nothing is displayed in the window except for a thick cursor. When I press any button being in that window, the program ends and this is what is displayed:
Enter height of box: Enter length of box: Enter width of box: Volume (cubic inches): 0 Dimensional weight (pounds): 0
RUN SUCCESSFUL (total time: 6s)
I'm completely new to C, so I don't know, what should appear when the program runs. When launching programs written in Python the console appeared, and now I'm confused.
When I tried to debug, it builded successfully again and then the console appeared with the line: "Enter height of box: "
, so it worked like I thought it should work, but I don't think this is the proper way to run programs.