If x = 3 and y = ++x + x++ why y=9 not 8 . And if y= x++ + x++; y =7. What is that ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

If x = 3 and y = ++x + x++ why y=9 not 8 . And if y= x++ + x++; y =7. What is that ?

16th Nov 2016, 7:38 PM
Александр Дубина
Александр Дубина - avatar
10 Answers
0
The increment operator before the value it is operating on means that it is incremented and then used. The opposite is true for when it comes after.
16th Nov 2016, 7:43 PM
NICKALL [EP]
NICKALL [EP] - avatar
0
ok. count that expression
16th Nov 2016, 7:48 PM
Александр Дубина
Александр Дубина - avatar
0
domagoj and rebecca_dg check your solution in compilator
17th Nov 2016, 4:24 AM
Александр Дубина
Александр Дубина - avatar
0
ты русский ( края )
16th Feb 2019, 2:14 PM
Rauch Bk
Rauch Bk - avatar
0
27¢|455666665"* позванить
16th Feb 2019, 2:15 PM
Rauch Bk
Rauch Bk - avatar
0
-32=5x+10+2x
9th Sep 2020, 4:06 PM
Tiandre Henderson
Tiandre Henderson - avatar
- 1
the first one im not sure. the second would be y = 3 + 4
16th Nov 2016, 8:03 PM
Junjie Gono
Junjie Gono - avatar
- 1
@Domagoj Puljic your answer is right but compilar in first example say y=9
17th Nov 2016, 5:23 AM
Александр Дубина
Александр Дубина - avatar
- 1
y would only equal 9 if x = 3 and y = ++x + ++x as this would be y = 4 + 5
18th Nov 2016, 7:45 PM
Graham Caswell
Graham Caswell - avatar
- 3
the second one is 6 not 7.. I explained it in the answers of your another question similar to this :) check it ;)
16th Nov 2016, 9:21 PM
Rebeka Asryan
Rebeka Asryan - avatar