C Code, Getting Unexpected Output | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 6

C Code, Getting Unexpected Output

https://code.sololearn.com/cgPNVDvpjS2k/?ref=app In this code pre increment and post increment making it difficult to understand

15th Feb 2022, 4:06 PM
Mask Man(What's in a name?)
Mask Man(What's in a name?) - avatar
2 Respuestas
+ 5
Read the warning.. tells sequence point issue. Result is undefined by standards. May produce different results in different compiler depends on its implementation.. cannot predict outcome same on different compilers in c/c++ Generally: Post increment : first it's value uses in statement and increments next. Pre increment : first it's value increments the it use it's value in statement. You can find many answers, using search bar... https://www.sololearn.com/Discuss/2038766/?ref=app https://www.sololearn.com/discuss/2976488/?ref=app https://www.sololearn.com/Discuss/2981058/?ref=app https://www.sololearn.com/Discuss/1690694/?ref=app https://www.sololearn.com/discuss/2924308/?ref=app read these ones, hope you can clearly understand then.....
15th Feb 2022, 4:40 PM
Jayakrishna 🇮🇳
+ 1
It's just game of associativity and precedence of increment operators (pre & post). Here in your code, it's executing from Right to Left and printing from Left to Right. https://www.geeksforgeeks.org/pre-increment-and-post-increment-in-c/
15th Feb 2022, 4:31 PM
Rupali Haldiya
Rupali Haldiya - avatar