Please explain value of y | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
2nd May 2017, 12:39 PM
Vaibhav Sharma
Vaibhav Sharma - avatar
5 Answers
+ 5
y=x++ + x++ * x++; x=3 y=3,then it's post-increment, x=4 y=3+4*,then again post -increment, x=5 y=3+4*5,then again post -increment ,x=6 y=23 x=6 Hope this helps
2nd May 2017, 12:52 PM
Rishabh Agrawal
Rishabh Agrawal - avatar
+ 13
@rishabh why do first x get post incremented at last while second and third x get post incremented even before product operator
2nd May 2017, 12:49 PM
Vaibhav Sharma
Vaibhav Sharma - avatar
+ 13
@rishabh I don't know why can't i understand it at first. Thanks a ton for your help
2nd May 2017, 1:49 PM
Vaibhav Sharma
Vaibhav Sharma - avatar
+ 5
No problem buddy. Happy coding...
2nd May 2017, 2:51 PM
Rishabh Agrawal
Rishabh Agrawal - avatar
+ 4
y=3+4*5; everytime it encounters x it's value is incremented and finally x becomes 6
2nd May 2017, 12:45 PM
Rishabh Agrawal
Rishabh Agrawal - avatar