0

How can I see the value of y after it is incremented on y = x++

On the example below if I run 'cout << y' it will show me the value 5 however the expression y=x++ indicates that it will assign y the value x then increment y. My question is how do I see the value of y after it is incremented? or is y not incremented when we say y=x++? Thanks a bunch! x = 5; y = x++; // x is 6, y is 5

13th Aug 2018, 5:47 AM
Helina Abye
Helina Abye - avatar
4 Answers
+ 2
Here y will be assigned value of x and than x will be incremented not y because you have use postfix increment in x not y. Hope this helps â˜șâ˜ș.
13th Aug 2018, 6:30 AM
Meet Mehta
Meet Mehta - avatar
0
x become 6 after y = x and that is why y = 5 In other words first y = x than x++
13th Aug 2018, 6:24 AM
B K
0
do y = ++x
13th Aug 2018, 6:25 AM
JME
0
Helina Abye Gebreyes similar question has been asked so many times previously...please use search before posting question to avoid repetition of duplicate questions: you may like to refer previous thread : https://www.sololearn.com/Discuss/489143/?ref=app
13th Aug 2018, 7:44 AM
Ketan Lalcheta
Ketan Lalcheta - avatar