A simple Interactive C Program Using Scanf Function

Want To Be Part Of my 7-Week's Lessons To Help You Propel Your Objectives & Eradicate Frustrations In Your Life?
Subscribe FREELY Right Now - click here!

C programming + scanf

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


//include your libraries here..
void main()
int number;

printf(“Enter an integer: \n”);     //prompt message
scanf(“%d”, &number);                 //read message

printf(“The number you entered is: %d”, number);


Enter an integer:
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

Valuable Feedback / Comment / Review From People Like You

  1. bapun says:

    this post is ver useful i have learn a lot from this post.thanx

  2. B.R.Arvind says:

    nice job done………its useful..

  3. jamaica says:

    its so useful thanks so much . God Bless 🙂

Speak Your Mind