Write a Program to print an Integer entered by user.

#include <stdio.h>
int main()
    int number;
    // printf() dislpays the formatted output 
    printf("Enter an integer: ");      

    // scanf() reads the formatted input and stores them
    scanf("%d", &number);    

    // printf() displays the formatted output
    printf("You entered: %d", number);
    return 0;


Enter an integer:5
You entered: 5


  • The printf() function displays Enter an integer: on the screen. Then, the scanf() function reads an integer data from the user and stores in variable number.
  • Finally, the value stored in the variable number is displayed on the screen using printf() function.