- 9
what is the value of x after the following code? please explain .
int x=8; int y=7; x++; x+=y--;
9 Réponses
+ 6
16
+ 2
tnx a lot from my heart
+ 1
But y-- == 6
+ 1
16
0
Need answer
0
What is the point of the -- after y? It does nothing? Fine x=16 but why have the -- after y? Is there any reason to ever have this code other than in this example?
0
Hi y friends , here is the explanation
x = 8, y = 7
x++ this value adds 1 to x i.e. ( x = 9 )
x += y-- gives x = x + y-- = 9 + 7 = 16.
Here 'y' value is taken as 7 because y-- is a postfix operation, so the current value of y is used for the calculation and is then decremented.
0
What is the value of x after this line of code executes?
int x = 9 % 4;
0
What is value of x after this code
Int x=2
X+=1
X*=2x-=2