+ 2
C++ code what is the answer of y
int a=5,y; y=++a + a++ + ++a; cout<<y;
13 Answers
+ 9
21 is perfect answer given by Netkos Ent and also compiler to
+ 7
can you define me how?
+ 7
thanks now i am satisfied.
+ 3
21
+ 3
Sure.
++a and ++a make a 7. Add the one from a++. 7 + 7 + 7 = 21
+ 3
i was going to say 19 (6 +6+7) but i am wrong and i see why...
+ 3
Not sure why Baptiste got downvotes since he is correct, it is undefined.
GCC and VC++ will indeed print out 21 here but clang prints 20.
Not sure where people keep learning this stuff but you should never use it again.
+ 3
Thanks for your support @Dennis !
They keep learning that because SoloLearn challenge has questions like that. The answer is the way the SoloLearn compiler (GCC) defined it, not the way all compilers defined it.
+ 3
such questions should not be used in challenges at all, or the answer is to be "undefined" and "compiler dependent".
+ 2
It is compiler dependant, so neither @Netkos or @Kostas are right or wrong
+ 1
No @Md Shakif, it is undefined behavior
0
what is the right answer?