+ 2
Anybody can explain how the output is 1
int x = 9; int y = 4; int z = x++-y--+(x+y); Console.Write(--z % 2);
2 Answers
+ 13
int z=x++ - y-- +(x+y);
9 - 4 + (10+3)
z= 9-4+13
= 18
--z=17
17%2= 1;
+ 2
x++ and y-- means post increment and increment value after line 3 i.e here, int z=x++-y--+(x+y)=9-5+13=18
and when --z%2 was used then here --z is pre decrement so it will decrete value by 1 ie --z=17
so output 17%2=1