C++ Program to Print the Number Entered by the User

In this tutorial, we will write a C++ program to print the number entered by the user. To write this program you should understand what is data types in C++.

#include<iostream>
using namespace std;
int main()
{
  // declare variable
  int number;

  // take input from end-user
  cout << "Enter an Integer: ";
  cin >> number;

  // display
  cout << "Entered Integer is: " << number << endl;

  return 0;
}

Output:-

Enter an Integer: 15
Entered Integer is: 15

In this C++ program to print the number entered by the user, We take a variable number of int data type which stores an integer value. Later we asked the user to enter an integer.

cout << "Enter an Integer: ";

The first line displays the message “Enter an integer: ” to the screen. The next line takes input from the user and store in the variable number.

cin >> number;

The below line displays the data stored in the variable number.

cout << "Entered Integer is: " << number << endl;

If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or do you find anything incorrect? Let us know in the comments. Thank you!

Learn More C++ Programming Examples,

Leave a Comment

Your email address will not be published. Required fields are marked *