Free programming examples and instructions

Simple CPP Program

Simple CPP Program for print a number entered by User

by Krishna

Posted on 27 Jun 2018 Category: c-plus-plus Views: 713

CPP Program to Enter a Number

This is a simple c++ program to illustrate the syntax of the programming language. In this example, we will learn how to get and print 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:

Click here to register

Popular articles