print an integer in C

How to print an integer in C Programming

Program to Print an Integer in C

Here is a C Program to Demonstrate you how to Print an integer in C programming where a user will input an integer which is then again printed back by the program. Input is taken using a scanf and the number is printed using printf.

#include <stdio.h>
int main()
{
int number;
// printf() Function dislpays the output
printf("Enter an integer: ");
// scanf() aceppts input from the user
scanf("%d", &number);
printf("You entered: %d", number);
return 0;
}

Output

Enter a integer: 25
You entered: 25

In this program, an integer variable number is declared.

Here in this Program,  The printf()  function displays Enter an integer: on the user’s screen. Then, the scanf() function accepts the input from the user and stores in variable numbers.

Now Finally, the value that was stored in the variable number is now displayed on the user’s screen using the  printf()function.

Leave a Reply

avatar
  Subscribe  
Notify of