A simple Interactive C Program Using Scanf Function

Reading data From Keyboard
scanf(“control string”, &variable01, &variable02, …);
=> The ampersand symbol, &, is very important. It’s an operator specifying the variable name’s address. Omitting it, might result into unexpected results.
How Does Scanf Behave During Execution
Consider: scanf(“%d”, &number);
=> This statement halts execution and waits for a value to be entered. That value will be stored in a variable ‘number‘ and is of type ‘integer‘ as specified by the format specifier ‘%d‘
=> The compiler will proceed once a number is typed in and the ‘Return‘ key is pressed.
The Code At Work
PROGRAM:
//include your libraries here..
void main()
{
int number;printf(“Enter an integer: \n”); //prompt message
scanf(“%d”, &number); //read messageprintf(“The number you entered is: %d”, number);
}
OUTPUT:
Enter an integer:
25
The number you entered is: 25
That’s it, a very simple program to keep things simple for you to understand how interactivity works. Do use the comment form below to add your part..
Other C Programming Articles:
=> Random Numbers in C programming
=> It’s Too Easy To Make This Simple, But Worse, Logical Error In Programming
this post is ver useful i have learn a lot from this post.thanx
nice job done………its useful..
its so useful thanks so much . God Bless