Java Program to find quotient without using division operator


In this program, You will learn how to find quotient without using division operator in Java.


2 = 10 / 5

0 = 5 / 10


Example: How to find quotient without using division operator in Java

Run it Now
import java.util.Scanner;

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

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

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

        while (a >= b) {
            a = a - b;
            q++;
        }

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

    }
}

Output:

Enter Two Numbers :9 3
The Quotient is :3