INPUT/OUTPUT Operators
The Standard Input Operator
- ">>" also called stream extraction operator is used to get an input.
- It is used with the standard input stream(cin).
- It stores the input in a variable.
cin>>In;
The Standard Output Operator
- "<<" also called stream insertion operator is used to display output.
- It is used with the standard output stream(cout).
- It prints text or some valueon the output screen.
cout<<"Hello";
Example: Printing a calculation.
cout<<2+7; //Prints '9'
- The difference comes out on the basis of use of quotes"".
Cascading of I/O Operators
- Cascading refers to taking multiple inputs or outputs in a single line.
- Multiple inputs takes place by placing ">>" between the different variable names.
- Multiple outputs occur by placing "<<" between the different outputs.Mostly we need to separate the calculations part with the rest.
cin>>In>>Put;
Example: Printing "The Sum of 2 and 5 is 7.
cout<<"The Sum of 2 and 5 is "<<2+5;
Comments
Post a Comment