Home Lifestyle C Program to Print an Integer (Entered by the User) – updated

C Program to Print an Integer (Entered by the User) – updated


C Program to Print an Integer (Entered by the User) In this example, the integer entered by the user is stored in a variable and printed on the screen 2021 updated

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

  • C Variables, Constants and Literals
  • C Data Types
  • C Input Output (I/O)
<img decoding=

Program to Print an Integer

#include <stdio.h>
int main() {   
    int number;
    printf("Enter an integer: ");  
    // reads and stores input
    scanf("%d", &number);

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

  • Enter an integer: 25
  • You entered: 25
  • In this program, an integer variable number is declared.

int number;
Then, the user is asked to enter an integer number. This number is stored in the number variable.

printf("Enter an integer: ");
scanf("%d", &number);

Finally, the value stored in number is displayed on the screen using printf().

printf("You entered: %d", number);

Counting sort is used for small integers it is an algorithm with a complexity of O(n+k) as worst case where ‘n’ is the number of elements and k is the greatest number among all the elements .

Types of Sorting Algorithms:

Additional Reading


If you found this post useful, don’t forget to share this with your friends, and if you have any query feel free to comment it in the comment section.

Thank you 😊 Keep Learning !

Previous articleHow to write C “Hello, World!” Program with Definition
Next articleC Program to Add Two Integers Elements (updated)


Please enter your comment!
Please enter your name here