C++ Exercises: Divide two integers without using multiplication, division and mod operator
4. Divide Two Integers Without *, /, or %
Write a C++ program to divide two integers (dividend and divisor) without using the multiplication, division and mod operators.
Sample Solution:
C++ Code :
Sample Output:
Dividend 7 Divisor 2 Result: 3 Dividend -17 Divisor 5 Result: -3 Dividend 35 Divisor 7 Result: 5
Flowchart:

For more Practice: Solve these Related Problems:
- Write a C++ program to perform integer division using recursion and subtraction to compute the quotient.
- Write a C++ program that divides two integers by iteratively subtracting the divisor from the dividend until the remainder is less than the divisor.
- Write a C++ program to implement division using a loop that counts the number of subtractions needed to reduce the dividend below the divisor.
- Write a C++ program to divide two numbers without using the multiplication, division, or modulus operators by employing bit shifting and subtraction.
?
C++ Code Editor:
Contribute your code and comments through Disqus.
Previous: Write a C++ program to reverse the digits of a given integer.
Next: Write a C++ program to calculate x raised to the power n (xn).
What is the difficulty level of this exercise?