C Program to Print an Integer - Read & Display User Input

Print an Integer Entered by the User

This example reads an integer from the user and prints it back to the console.

#include <stdio.h>
int main() {
    int number;
    printf("Enter an integer: ");
    scanf("%d", &number);
    printf("You entered: %d\n", number);
    return 0;
}
Enter an integer: 25
You entered: 25
        

The program declares an int variable, prompts the user and reads a value into it. The printf() call then prints the value in a formatted string. Using scanf() ensures that the user’s input is stored in the variable before printing.

Sai Kishore Randhi, author
About the author

Sai Kishore Randhi

Embedded systems, VLSI, and chip design

Sai Kishore writes about embedded systems, VLSI, chip design, and the programming concepts behind modern hardware.

View LinkedIn profile ↗