Why is the output of the following C code 10 41 ? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 1

Why is the output of the following C code 10 41 ?

int main() { int e=5,f=0; f=(++e) + (++e) + (++e) + (++e) + (++e); printf("%d %d\n",e,f); return 0; } It should be 10 40 but it's coming out to be 10 41.

8th Sep 2019, 3:48 PM
Rishu Kumar
Rishu Kumar - avatar
1 Réponse
+ 1
Using ++ operator more times in single line is UNDEFINED. You never know what will come up, depends on compiler or compiler flags
8th Sep 2019, 4:08 PM
Elva
Elva - avatar