I've been doing questions that require us to give the output and up until now I thought my concepts were clear until I came to these specific questions. I have usually read statements with pre and post increment operators from left to right and I've never faced a problem...until...
Normally, code like this:
Should according to me, reading from left to right, give an output 25+26 i.e. 51.
But it gives 52!
Even reading from right to left does not give that!
Then, I have also come across code like this:
1 2
|
int i = 20;
cout<<i<<i++<<++i;
|
Which initially, I had read from left to right to give an output of (considering spaces between for clarity) 20 20 22 BUT actually gives an output of 21 21 22 which basically to me meant that we had read it from right to left.
I really need someone to shed light on what seems to me pretty confusing!