Print a Integer Entered by a User

Posted By on September 26, 2014

Download PDF
Print a Sentence
Add Two Integers

Source Code

#include <stdio.h>
int main()
    int num;
    printf("Enter a integer: ");
    scanf("%d",&num);  /* Storing a integer entered by user in variable num */
    printf("You entered: %d",num);
    return 0;


Enter a integer: 25
You entered: 25


In this program, a variable num is declared of type integer using keyword int. Then, printf() function prints the content inside quotation mark which is “Enter a integer: “. Then, the scanf() takes integer value from user and stores it in variable num. Finally, the value entered by user is displayed in the screen using printf(). Learn more about how printf() and scanf() works in C programming.

Print a Sentence
Add Two Integers

Download PDF

Posted by Akash Kurup

Founder and C.E.O, World4Engineers Educationist and Entrepreneur by passion. Orator and blogger by hobby