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