C++ Program to Print Number Entered by User

With the help of C++ program, compiler can display the number entered by a user. Generally, the compiler takes input from a keyword and displays the output in the monitor or screen. C++ uses cin statement to take input from the user and cout statement to display the result in the screen. Let us look at the C++ example below to print number entered by a user:

C++ Program to Print Number Entered by User

#include <iostream>
using namespace std;
int main() {
   int num;
   cout<<"Enter the number:\n";
   cin>>num;
   cout<<"The number entered by user is: "<<num;
   return 0;
}

The output of the above program is:

Output:

Enter the number: 2
The number entered by user is: 2

 

SHARE C++ Program to Print Number Entered by User

You may also like...

Leave a Reply

Your email address will not be published.

Share