what is the true output of this code?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

what is the true output of this code??

there is a problem with the output of some codes. actually it can be depend on C compiler. Eg: according to the C compiler of sololearn app, this tagged code's output is 22. but when you try it another app u can have a answer is 21. it is also a possible answer https://code.sololearn.com/cW4mQ0W12HAd/?ref=app

27th Apr 2019, 5:13 PM
T.M.Pathmika Weerarathna
T.M.Pathmika Weerarathna - avatar
1 Answer
+ 2
This is known as undefined behaviour. This thing can be seen in C++ too! Think of BODMAS rule. Ecery language implement mathematical expressions according to it. But in C languages there is no common way of executing increments or decrements. So different C/C++ compilers execute those instructions differently. In fact all of them are right. Therefore it is recommended not to modify the value of a variable in a single statement because the value of that variable is truly undefined.
27th Apr 2019, 5:21 PM
Seniru
Seniru - avatar