Java Program to find modulus of two numbers

Get two integer numbers, divide both the integers and display  the remainder.

Sample Input 1:

6 5

Sample Output 1:


Sample Input 2:

28 4

Sample Output 2:


Try your Solution

Strongly recommended to Solve it on your own, Don't directly go to the solution given below.

public class Hello { public static void main(String args[]) { //Write your code here } }

Program or Solution

import java.util.*;
class Modulus
     public static void main(String args[])
         int Input1,Input2,mod;
         Scanner sc=new Scanner(;

         System.out.println("Enter The Input 1:");
         System.out.println("Enter The Input 2:");
         System.out.println("The Output Is:\n"+mod);


Program Explanation

Get two integers Input1 and Input2 (using scanner class) divide Input1 by Input2 , then store remainder in mod (mod=Input1%Input2 , Note "%" operator gives remainder) print the value of mod (using system.out.println)