I am a newbie in C, but I want to learn a lot, and I wrote this very simple program in which the user is prompted to enter the number using the keyboard. Before this, the message βPlease enter the real number using the keyboardβ should be displayed, and then a message confirming the value of the number they dialed to the user. (code below)
The problem is that when I create my executable file and run it, it first asks for the value x and displays the message "Please enter the real number using the keyboard" only after the user dialed the number! What have I done wrong? Can someone explain this strange behavior to me as I typed my instructions in good order?
#include <stdio.h> /* package to read and to write variables */
int main(void)
{
float x;
printf("Please type a real number with the keyboard\n");
scanf("%f", &x);
printf("You just typed %f, congratulations !", x);
return 0;
}