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


In this program, we will print the value of the integer on the screen that is entered by the user. Although the code for this particular program will be very easy. We all should be aware of some concepts. Those topics are:

  • Declaration of a variable,
  • Format specifiers,
  • Addresses.



int main()


int a; // declaration of variable ‘a’

printf("Enter the value of integer:\n");


printf("Value of integer is %d",a);

return 0;





A variable ‘a’ of ‘int’ data type is declared because there is a need of an integer type variable which will store the integer value entered by the user.

A message is printed (with the use of ‘printf’ function) on the screen asking user to enter an integer type value.

scanf(“%d”,&a); , ‘scanf’ function is used to take input from the user. Since the value entered by user is of ‘int’ data type thus %d format specifier is used.

The value entered by user will get stored at the address of a.

printf(“Value of integer is %d”,a); ,this statement gets printed as it is along with the value of ‘a’ at the place of %d.

So, successfully we have stored the value input by the user at the address of ‘a’. Thus, the value entered by the user will be stored in the variable ‘a’.



  • Barry Allen

    A Full Stack Developer with 10+ years of experience in different domain including SAP, Blockchain, AI and Web Development.

    View all posts


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.