Is there any advantage of multiple insertion operators after cout over single insertion operators after cout. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Is there any advantage of multiple insertion operators after cout over single insertion operators after cout.

24th Jan 2019, 3:56 PM
Akash Kumar
Akash Kumar - avatar
3 Answers
+ 2
Code readability. Also, there is a bit less to type. I personally prefer this: int a = 42; cout << "The answer is " << a << "!" << endl; ...over this: int a = 42; cout << "The answer is " cout << a cout << "!" cout << endl;
24th Jan 2019, 4:10 PM
Zen
Zen - avatar
+ 2
Because I want to print the value of the variable a instead of the character a, obviously.
24th Jan 2019, 5:07 PM
Zen
Zen - avatar
+ 1
Why dont you prefer this ? cout << "This answer is a !" << endl; I am asking
24th Jan 2019, 5:04 PM
Akash Kumar
Akash Kumar - avatar