+ 1
why the answer is 3
What is the output of this code? int x = 15; int y = 6; x %= y; Console.WriteLine(x);
2 Answers
+ 3
hi there đ
x is assigned a value of 15
y is assigned a value of 6
x%=y means x = x% y
Modulus operators return the remainder after the Operation.
So here
x = x % y
=> 15 % 6
=> 3 i.e the remainder.