+ 3

Different results of compilers in c++ code. [Solved]

int b= 7; cout<< (++b + b++); why the answer is 17 and not 16?, I was checking in many compilers, some gave 16

30th Mar 2018, 11:27 PM
Anthony Wainer
Anthony Wainer - avatar
3 Respostas
+ 1
correct answer is 16, its all about pre increment and post increment.
31st Mar 2018, 1:55 PM
Neeraj Jangra
Neeraj Jangra - avatar
+ 1
that's right Meraj according to the definition, ++b = 8, b++ = 8, thus, the answer is 16, but the majority compilers to gave 17
31st Mar 2018, 3:25 PM
Anthony Wainer
Anthony Wainer - avatar