+ 1

why the answer is 3

What is the output of this code? int x = 15; int y = 6; x %= y; Console.WriteLine(x);

29th Jun 2020, 3:18 AM
Tyler Paul
Tyler Paul - avatar
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.
29th Jun 2020, 3:35 AM
Nilesh
Nilesh - avatar