Program In C++ To Display The Number Typed By The User

This software uses the cin statement to read the user-inputted integer and outputs it using the cout command.

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

   //printing the number
   cout<<"The number entered by user is: "<<num;

   return 0;


Enter any number: 121
The number entered by user is: 121


Related Articles

Leave a Reply

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

Back to top button