Tuesday 22 September 2015

Cascading Of I/O Operators

Leave a Comment
Consecutive amount of input and output operators (“>>” and “<<”) in C++ can be concatenated.

For example, the output statements can also written as follows:

cout<<"The sum of 2+5="<<2+5<<"\n";


int x,y,z;

Each consecutive output operator is applied in turn to cout. For readability, the concatenated output statement may span several lines. The following three lines make up a single output statement.

       cout<<"The sum of"

Likewise, consecutive happenings of input operator (>>) can also be concatenated as follows:

       cout<<"Enter two numbers:";


The two values given by the user are correctly read into value1 and value2. (The input operator “>>” discards all white spaces (blanks, tabs, newline etc.) between two following input values).

From the above examples, it is clear that one statement can have many input or output operator.

The multiple use of input or output operators (“>>”or”<<”) in one statement is called cascading of I/O operator.

The statement using multiple output operators (“>>”) is said to be cascading output operator and the statement connecting many use of input operators (“<<”) is said to be cascading input operator.

If You Enjoyed This, Take 5 Seconds To Share It

0 Questions: