C Program to Print a Number
C program to print a number
  • Post author:
  • Reading time:1 mins read
  • Post category:C Programs

In this article, you will be able to learn to write a program print an Integer entered by the user in c programming language.

C Program to Print an Integer Entered by the User

Methodology

  • Input an Integer.
  • Print the integer using printf().

Program

#include <stdio.h>
int main()
{
  int number;
  printf("\n\tC Program to Print a Number");
  printf("\n\tEnter an integer to print\n\t");
  scanf("%d", &number);
  printf("\tEntered integer is: %d\n\n", number);
  return 0;
}

Output

	C Program to Print a Number
	Enter an integer to print
	7
	Entered integer is: 7
C program to print an Integer entered by the user

Code explanation

First, declare an int type variable. Then using printf() function print “Enter an integer to print” then using scanf() function read the number inputted by the user and store it in the variable previously declared. Then print that number using printf() function print the number stored in that variable.


People also ask for

How do I print a number?

You can print a number by storing it then outputting on to console by using any output functions.

How do I print a number without printf?

You can print a number using putw() function which prints an integer to console.