codescracker


c++

C++ Program to Get Input from User



« Previous Program Next Program »


Get Input from User in C++

To receive or get input from the user, use cin>>input. Here, input is the entered number, character, name, etc. The cin>> is used to receive the input data like integer, character, float, etc.

C++ Programming Code to Get Input from User

Following C++ program ask to the user to enter a number, then display the entered number on the screen :

/* C++ Program - Get Input from User */
		
#include<iostream.h>
#include<conio.h>
void main()
{
	clrscr();
	char name[20];
	int num;
	cout<<"Enter a number : ";
	cin>>num;
	cout<<"You entered "<<num;
	getch();
}

When the above C++ program is compile and executed, it will produce the following result:

receiving input in C++ Programming

Same Program in Other Language

You may like the same program in other programming languages:


« Previous Program Next Program »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test