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

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

Leave a Reply Cancel reply

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

Programs

  • C Programs
  • Java Programs
  • C++ Programs

Copyright © 2012 – 2022 BeginnersBook . Privacy Policy . Sitemap