beginnersbook.com

  • Home
  • All Tutorials
    • Learn Servlet
    • Learn JSP
    • Learn JSTL
    • Learn C
    • Learn C++
    • Learn MongoDB
    • Learn XML
    • Learn Python
    • Learn Perl
    • Learn Kotlin
    • Learn jQuery
  • Core Java
  • OOPs
  • Collections
  • Java I/O
  • JSON
  • DBMS

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

Recently Added..

  • JSON Tutorial
  • Java Regular Expressions Tutorial
  • Java Enum Tutorial
  • Java Annotations Tutorial

Copyright © 2012 – 2022 BeginnersBook . Privacy Policy . Sitemap