In this **Java program**, let’s learn **how to compute quotient and remainder** in your Java sourcecode.

## How to Compute Quotient and Remainder in JAVA?

RUN CODE SNIPPET### Example: To find Quotient and Remainder

public class Main { public static void main(String[] args) { int num1 = 50, num2 = 3; int quotient = num1 / num2; int remainder = num1 % num2; System.out.println("Quotient = " + quotient); System.out.println("Remainder = " + remainder); } }

### OUTPUT

Quotient = 16 Remainder = 2

In the above program, the integers 50 and 3 are stored in the variable num1 and num2.

The number 50 is dividend and 3 is the divisor. We are calculating the Quotient and remainder by dividing 50 by 3.

Here we use the “/” operator to find the quotient and the “%” operator to find the remainder. Since both the dividend and divisor are integers, the result also is an integer.

Using the println function we print the result on the screen.

## Leave a Review