# Perform division without using division operator

What you will learn here about java programming

• perform division without using division operator

Perform division without using division operator is one of the common interview question. It is very easy to perform division without using division operator by using subtraction logic. Here we will how to perform division without using division operator using subtraction.

## Perform division without using division operator

```public class Division
{
static int divide(int dividend, int divisor)
{
//first getting sign of division
int Result_sign = ((dividend < 0) ^ (divisor < 0)) ? -1 : 1; //converting negative numbers to positive dividend = Math.abs(dividend); divisor = Math.abs(divisor); // Initialize the quotient int quotient = 0; //performing division using subtraction logic while (dividend >= divisor)
{
dividend -= divisor;
++quotient;
}

//final result
return Result_sign * quotient;
}

public static void main (String[] args)
{
int dividend=-12;
int divisor=3;
int quotient=divide(dividend,divisor);
System.out.println(dividend+ " / "+divisor+" = "+quotient);
}
}

```

-12 / 3 = -4