Last question in c++ basic 11/11 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Last question in c++ basic 11/11

I dont understand why the answer is 4 and not 5. Can anybody explain?

24th Jun 2018, 4:26 PM
eliakim
7 Answers
+ 2
No, 3 is just read first
24th Jun 2018, 5:45 PM
LONGTIE👔
LONGTIE👔 - avatar
+ 1
because a++ = 3 and b = a++ so ++b = 4
24th Jun 2018, 4:29 PM
LONGTIE👔
LONGTIE👔 - avatar
+ 1
but a is initially 3, so doesnt b = a++ make b = 4?
24th Jun 2018, 4:36 PM
eliakim
+ 1
because b equals 3 before 1 is added
24th Jun 2018, 4:46 PM
LONGTIE👔
LONGTIE👔 - avatar
+ 1
x++ = x + 1 ++x = 1 +x
24th Jun 2018, 4:47 PM
LONGTIE👔
LONGTIE👔 - avatar
+ 1
so a = 3 b = a++ b = 3 ? so the ++ is not really necessary?
24th Jun 2018, 5:36 PM
eliakim
0
or it just has no meaning in this scenario?
24th Jun 2018, 5:37 PM
eliakim