Please tell me the values of "a" and "b" during the operation in the program. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Please tell me the values of "a" and "b" during the operation in the program.

int a=10, b= 5; (a++) +a+= (a++) + b + (++a) +(a++) and then print the values of a and b. I am a beginner, so if there is a mistake , please correct it and then solve and let me know my mistake as well as tell the values of "a" and "b" during the operation.

27th Oct 2017, 2:57 PM
Shashank shekhar
Shashank shekhar - avatar
3 Answers
+ 3
Your other question also contains relevant answers re: undefined behavior. https://www.sololearn.com/Discuss/807745/?ref=app I thought there was at least one more Q&A with very similar format. Is this some class testing compiler-specific questions?
27th Oct 2017, 3:20 PM
Kirk Schafer
Kirk Schafer - avatar
+ 2
You can't have (a++)+a before the += operator. It must be an assignable location.
27th Oct 2017, 3:17 PM
John Wells
John Wells - avatar
+ 2
In my opinion, the biggest mistake is getting entangled with wierd sintax that makes your code wrong (as in this case) or potentially compiler dependant.
27th Oct 2017, 3:28 PM
seamiki
seamiki - avatar