java

Java Program to Find Quotient and Remainder

In this tutorial, we are going to see how to find the quotient and the remainder of a division in Java.

In the following example, we have two integers n1 and n2 and we find the quotient and the remainder when n1 is divided by n2, so we can say that n1 is the dividend and n2 is the divisor.
 

Java Program to Find Quotient and Remainder
public class Main {
    public static void main(String[] args) {
        int n1 = 11, n2 = 2;
        int q = n1 / n2;
        int r = n1 % n2;
        System.out.println("The quotient is: " + q);
        System.out.println("The remainder is: " + r);
    }
}

Output:

The quotient is: 5
The remainder is: 1
[st_adsense] mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *