Skip to content
Home » Blog » C Program to Print an Integer in Just 3 Lines of Code

C Program to Print an Integer in Just 3 Lines of Code

C Print Integer

In this Program, you’ll learn how to Print Integer.

In this program of C Print Integer, integer entered by the user is stored in a variable. Then, that variable is displayed on the screen using printf( ) function.

In C language we have data types for different types of data, for integers, it is int, for characters it is char, for floating point data it’s float and so on. For large integers, you can use long or long long data type.

To store integers which are larger than (2^18-1) which is the range of long long data type you may use strings. In the below program we store an integer in a string and then display it.

To understand this example of C Print Integer, you should have the knowledge of following C programming topics:

  • Constants
  • Variables
  • Data Types
  • Input-Output

Program to Print an Integer

#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 a integer: 35
You entered: 35

C Program to Print an Integer

In this program, an integer variable number is declared.

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.

Ask your questions about C print integer and clarify your/others doubts by commenting. Documentation.

Related Program

  1. C Program to compute Quotient and Remainder.
  2. C Program to Find ASCII value of a Character.
  3. C Program to Swap two Numbers.
  4. C Program to Find the size of int, float, double and char.
  5. C Program to Multiply two floating point Numbers.
  6. C Program to Implement stack.
  7. C Program to Implement circular linked list List.
  8. C Program to calculate compound interest.