0

Find the output?

main() { int i=0; cout<<i++; cout<<++i; }

8th Jul 2017, 8:22 PM
Gopal Yadav
Gopal Yadav - avatar
2 Answers
+ 6
Usually i would be initialized to 0, so the output would be 02. But it can depend on the compiler. Heres more info https://stackoverflow.com/questions/30172416/uninitialized-variable-behaviour-in-c
8th Jul 2017, 8:32 PM
Karl T.
Karl T. - avatar
+ 1
To add: Historically, ++i would take greater preference over a call or operation, whereas i++ does not. Though it may be compiler dependent, it should be "02". But these things are why we always use parenthesis.
8th Jul 2017, 11:12 PM
Jamie
Jamie - avatar