+ 3

What is the true OUTPUT of this code?

According to the C compiler of sololearn app , the answer is 22. when i try this code in another app, i had a answer is 21. which one is the correct one? Is this depend on the compiler? https://code.sololearn.com/cW4mQ0W12HAd/?ref=app

26th Apr 2019, 11:54 AM
T.M.Pathmika Weerarathna
T.M.Pathmika Weerarathna - avatar
1 Respuesta
+ 2
that is an example of undefined behavior, where the program run in unpredictable way. for example in you case ++i + ++i + ++i we dont know when ++i is being executed for the first time. its all based on compiler implementation on how to handle this (cmiiw) so the result might be different on different compiler
26th Apr 2019, 12:03 PM
Taste
Taste - avatar