What is the output sequence? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

What is the output sequence?

int a=0; cout <<a++<<a++<<a++<<endl; Why the output is 210? Why it is not 012?

11th Mar 2017, 12:46 PM
Alion Lee
Alion Lee - avatar
1 Answer
+ 5
In complex cascading increment/decrement couts like this, statement is evaluated right to left. So starting from right, a++ displays 0 a=1 a++ displays 1 a=2 a++ displays 2 a=3 Now, display will be done as usual (left to right). So output is 210
11th Mar 2017, 3:13 PM
Rohan
Rohan - avatar