0

How does modulo work please if i entered 10 in this if statement.

If(scn%2==0){System.out.println("even");}

22nd Aug 2017, 9:41 AM
D_Stark
D_Stark - avatar
2 ответов
+ 9
Modulus (%) operator returns the division remainder (what is left over). 10 divided by 2 gives 0 as a remainder ( 2*5 = 10, 10-10 = 0 ). Therefore, if( 10%2 == 0 ) { // condition true System.out.println("even"); //outputs even } It's the basic Math in which we divide two numbers for getting a remainder :D
22nd Aug 2017, 10:02 AM
Dev
Dev - avatar
0
ohhhh cool i get it thanks
22nd Aug 2017, 10:22 AM
D_Stark
D_Stark - avatar