Display the Number Entered by User
This program takes the number entered by user using cin statement and prints it using cout statement.
Example: Program to display the number entered by user
.
#include <iostream>
using namespace std;
int main(){
/* I have used double data type so that user can
* enter integer as well as floating point number
* If you want to input and display only integer
* then use int instead of double, like int num; */
double num;
//This will display the string in quotes as it is
cout<<"Enter any number: ";
//This will store the input number in the variable num
cin>>num;
//printing the number
cout<<"The number entered by user is: "<<num;
return 0; }
Output
Enter any number: 121
The number entered by user is: 121
Leave Comment