+ 1

Can you guys plz help me that how does this calculation result come 5

public class Program { public static void main(String[] args) { int value = 23; int res = value % 6; System.out.println(res); } }

24th Jun 2017, 9:35 AM
Gopal Biswas
Gopal Biswas - avatar
2 Respuestas
+ 12
% (modulus) gives the remainder after the division of any two numbers. Here, you divide 23 by 6. After the division, the remainder which is left out is 5 as 6*3 = 18 and 23-18 = 5. It never takes 6*4 = 24 as it will exceed 23 (the numerator). P.S. It results to the remainder after the division of 23 by 6 ^^
24th Jun 2017, 9:39 AM
Dev
Dev - avatar
+ 2
ooooo.. thank you so much buddy.. you are so helpful
24th Jun 2017, 9:42 AM
Gopal Biswas
Gopal Biswas - avatar