Java Program to find quotient and remainder


In this program, You will learn how to find quotient and remainder in Java.


2 = 10 / 5

0 = 10 % 5


Example: How to find quotient and remainder in Java

Run it Now
import java.util.Scanner;

class Main {
    public static void main(String args[]) {

        int q,r,a,b;
        Scanner sc = new Scanner(System.in);

        System.out.print("Enter Two Numbers :");
        a = sc.nextInt();
        b = sc.nextInt();

        q = a / b;
        r = a % b;

        System.out.println("\nThe Quotient is :"+q);
        System.out.println("The Remainder is :"+r);

    }
}

Output:

Enter Two Numbers :9 2
The Quotient is :4
The Remainder is :1