0
tell me why the output of this code is 3 ???
why is the output of this code 3 ??? int y = 3; int x = 10; int z = y - (x % --y); Console.Write(z);
5 odpowiedzi
+ 3
% operator gives the remainder of a division.
So, z=y-(x%--y)
z=3-(10%2)
z=3-0
z=3
And then Z is being printed to the console =)
+ 2
Роман Жигунов I don't understand what you're saying. "Won't y be equal to 2?" y is equal to 2 right? At first y was given the value 3, but the expression --y decremented the value of y by 1 and made it 2
+ 2
Y isn't decremented until - - y appears. So, the first y is still 3 because it appears before the second.
+ 1
when using the step with entry function (F11), it shows me that y is assigned the value 2
won't y be equal to two?
z = 2 - (10% 2);
+ 1
Melodie Bernard, this is what I needed, thanks)