Variables in C++

Variables is a name given to memory location. 

            int x =10;                    

here, x is a integer variable.                                                    

Integer variable x is a name given to memory location and where we stored integer value10.

Initialize variable

we can also initialize variables as below.

int  a,b,c;

a=10;
b=20;
c=30;

Here, we have initialized three integer variable a,b & c. variable  ‘a’  stores 10, variable ‘b’ stores 20 and variable ‘c’ stores 30.

Initialize multiple variable

we can also initialize multiple by comma separated list.

int a;             
char b;       
float c;
a=10;
b=’S’;
c=11.23

How to take input from user in C++

In C++ we can take a input from user by using “cin”.

In C++ , “cin” is an  object of class istream. 

“cin” object  is used to take the input from the standard input device i.e. keyboard.

In “cin” ,   “c” refers to “character” and ‘in’ means “input”, hence cin refers “character input”.

“cin” is used with the extraction operator (>>) for receive a stream of characters from user.

Syntax  of cin is:

Example

How to take multiple input from user in C++

In C++ we can also take a multiple input at a time by using cin object.

Syntax to take multiple input at time by using cin.

cin >> Variable1 >> Variable2 >> … >> VariableN;

Example:

Output: