C++ Input Statement
cin object of iostream is used to get input from console device (keyboard). It is read as (see-in). cin is always used with extraction operator >>. Each cin statement must ends with semicolon.
Syntax of cin statement
Syntax of cin statement is as.
cin >> variable ;
cin
cin is the object name from istream class. Which is part of iostream.
>> (Extraction Operator)
Extraction operator is used with cin object object it can be used multiple times with single cin object.
Variable
Variable is used used to save data/values which may change during program execution. cin object get input from console device (keyboard) and save it in provided keyboard.
Example of cin Statement with single insertion operator.
#include<iostream>
using namespace std;
int main() {
int a,b;
//displaying message for taking input.
cout<<"Provide First Input:";
cin>>a;
cout<<"Provide Second Input:";
cin>>b;
// printing value of input.
cout<<a<<b;
return 0;
}
Example of cin Statement with multiple insertion operator.
#include<iostream>
using namespace std;
int main() {
int a,b;
//displaying message for taking input.
cout<<"Provide First and Second Input:";
cin>>a>>b;
// printing value of input.
cout<<a<<b;
return 0;
}