Menu
Topics Index
...
`

Find Modulus - Java Example Program


Find Modulus
class FindModulus
{
    public static void main(String arg[])
    {
        int x = 32;
        double y = 36.75;
        
        System.out.println("x mod 10 = " + x % 10);
        System.out.println("y mod 10 = " + y % 10);
    
    }
}
OUTPUT

x mod 10 = 2
y mod 10 = 6.75

DESCRIPTION

When 32 is divided by 10, the quotient will be 3 and the modulus (or remainder) will be 2. Similarly when 36.75 is divided by 10, the quotient will again be 3, where as the modulus will be 6.75.

© meritcampus 2019

All Rights Reserved.

Open In App