adplus-dvertising

C Program to Print an Integer entered by the user

frame-decoration

C Program to Print an Integer entered by the user

Problem Description

This is very basic program in C language. It takes an integer as input from the user and displays it as output. Basically, this program illustrates the working of printf ans scanf function. This C program also demonstrates how integer variables are stored and accessed.

C Program to Print an Integer entered by the user - Source code
     
                
  /* C Program to print an integer entered by the user */

#include <stdio.h>

int main()
{
    int number;

    printf("Enter an integer: ");

    scanf("%d", &number);

    printf("Integer entered by you: %d", number);
    return 0;
}
     
      

Program Output

Case 1:

Enter an integer: 590
Integer entered by you: 590


Case 2:

Enter an integer: 421
Integer entered by you: 421

Program Explanation

1. In this program an integer variable number is declared.

2. A message is displayed on the screen using printf function.

3. The integer entered by the user is stored in the variable number using scanf function.

4. At last, the stored integer is displayed on the screen using the printf function.