c program to print a number
C program to print a number
  • Post author:
  • Reading time:1 mins read
  • Post category:Programming

In this tutorial you will learn how to print a number in c programming language. Number we are ptinting is int (integer datatype).

C program to print an Integer entered by the user

#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.