Java Program to find quotient without using the division operator
In this program, You will learn how to find quotient without using a division operator in java.
2 = 10 / 5
0 = 5 / 10
Example: How to find quotient without using division operator in java.
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("Quotient is:" + q);
}
}
Output:
Enter two numbers:10 4
Quotient is:2