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: 1046
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.
#include<iostream>
#include<conio.h>
using namespace std; // scope of the identifiers that are used in the program.
void main()
{
int number;
cout<<”Enter the number :”;
cin>>number;
cout<<”Entered number :”<<number;
getch();
}
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.
OUTPUT
Latest posts in c-plus-plus