Using I/O Operators

Posted On
Socialize It →
1
Input coming from the user’s terminal referred to as element to as standard input is tied to the predefined iostream cin and output directed to the user’s terminal, referred to as standard output, is tied to the predefined iostream cout.

Output Operator “<<”

The output operator (“<<”) also called stream insertion operator is used to direct a value to standard output.

For Example

Cout<<” The Sum of 2+5=” ;
Cout<<2+5 ;

The two statements will produce the following output :
The Sum of 2+5=7

Now observe the output of following set of statements:

Cout<< “The sum of 2+5=”;
Cout<<2+5;
Cout<< “\n”;
Cout<< “ The result of 8-2 is”;


The output of above set of statement will be follows:

The Sum of 2+5=7
The Result of 8-7 is 6

The two characters sequence \n represents the new line characters. When written, the newline character causes the successive output to be directed to the next line otherwise each successive cout display the output at the next column after the previous output. Therefore, the result of first two statements is displayed in the same line. Thereafter encountering \n, the output of next two statements are displayed at the next line.

Input Operator “>>”

The input operator (“>>”) also known as stream extraction operator is used to read a value from standard input. 

1 comment:

  1. 1xbet korean - legalbet.co.kr
    › app › korean-bets › app › korean-bets It is best william hill that you choose a 다파벳 team with more than 30 years of experience in the industry of online gaming. The best thing about the platform is 1xbet

    ReplyDelete

'