Answers for "Divide without / operator"

0

Divide without / operator

Numbers -- Divide without / operator
Write a method that can divide two numbers without using division operator
 
Solution:
public static void divides(int num1, int num2) {
if(num2==0) {
System.out.println("Invalid Number");
return;
}
System.out.print(num1 +" divide by "+num2 +" is: ");
int count =0;
while(num1 >= num2) {
num1 -= num2;
count++;
}
System.out.println(count+" and remainder is "+num1);
}
Posted by: Guest on September-29-2021

Code answers related to "Divide without / operator"

Browse Popular Code Answers by Language