View All C Programs

 Previews Example  View All C Programs Next Example 

Program to Print a Integer Entered by a User in C

In this program, a variable num is declared of type integer using keyword int. The printf() function prints the content inside quotation mark which is "Enter a integer: ". Then, the scanf() takes integer value from user and stores it in variable num. Finally, the value entered by user is displayed in the screen using printf().
#include <stdio.h>
#include <conio.h>
main()
{
    int num;
    printf("Enter a integer: ");  
    scanf("%d",&num);  /* Storing a integer entered by user in variable num */
    printf("You entered: %d",num);
    getch();
}    
Result
Enter a integer: 12

You entered: 12