BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

C++ Program to Display the Number Entered by User

Last Updated: September 7, 2017 by Chaitanya Singh | Filed Under: C++ Programs

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

Top Related Articles:

  1. C++ Program to add two numbers
  2. C++ Program to Find and display the Transpose of a Matrix
  3. C++ Program to Add Complex Numbers
  4. C++ Program to Find largest element in an array
  5. C++ Program to Find Second Smallest Element in an Array

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

Leave a Reply Cancel reply

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

Copyright © 2012 – 2025 BeginnersBook . Privacy Policy . Sitemap