- 9

what is the value of x after the following code? please explain .

int x=8; int y=7; x++; x+=y--;

31st Jul 2019, 4:42 AM
ND MORSALIN
ND MORSALIN - avatar
9 Réponses
+ 6
16
16th Oct 2022, 5:14 AM
Galang Joan Marie Francisco
Galang Joan Marie Francisco - avatar
+ 2
tnx a lot from my heart
31st Jul 2019, 7:00 AM
ND MORSALIN
ND MORSALIN - avatar
+ 1
But y-- == 6
1st Aug 2019, 12:29 AM
Chitra Reddy Chitra
Chitra Reddy Chitra - avatar
+ 1
16
27th Nov 2022, 2:05 AM
Dhana kalasani
Dhana kalasani - avatar
0
Need answer
16th Sep 2022, 11:57 AM
ooha
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?
10th Jan 2023, 6:14 PM
Dave A
Dave A - avatar
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.
16th Feb 2023, 6:36 AM
Jembere Guta
Jembere Guta - avatar
0
What is the value of x after this line of code executes? int x = 9 % 4;
2nd Mar 2023, 7:09 PM
Terrick_Antonio Ashcraft_Jr
Terrick_Antonio Ashcraft_Jr - avatar
0
What is value of x after this code Int x=2 X+=1 X*=2x-=2
8th Jul 2023, 8:56 AM
Harsha Singam
Harsha Singam - avatar