Free programming examples and instructions

c++ program to print number entered by user

basic c++ program for how to print number entered by user

by Krishna viswambharan

Posted on 19 Jul 2018 Category: C-plus-plus Views: 35

Edited on 25 Jul 2018

Print Number Entered by User

This is a simple c++ program to illustrate the syntax of the programming language. In this example, we will learn how to get and display a number entered by a user using c++ ‘cin’ and ‘cout’ statements.

using namespace std;  // scope of the identifiers that are used in the program.
void main()
          int number;
          cout<<”Enter the number :”;
          cout<<”Entered number :”<<number;

The program starts with  main().  This program asks the user to enter a number, which is stored in variable ‘number’ using the statement ‘cin’. The output is displayed using ‘cout’.

NOTE: some old versions of c++ use header  file <iostream.h>. so we should use iostream.h if the compiler does not support ANSI C++ features.


Latest posts in C-plus-plus

Leave a Comment: