Search code examples
c++calgorithmarraysdigits

Array Division - What is the best way to divide two numbers stored in an array?


I have two arrays (dividend, divisor):

dividend[] = {1,2,0,9,8,7,5,6,6};
divisor[] = {9,8};

I need the result (dividend/divisor) as:

quotient[] = {1,2,3,4,5,6,7};

I did this using array subtraction:

  • subtract divisor from dividend until dividend becomes 0 or less than divisor, each time incrementing quotient by 1,

but it takes a huge time. Is there a better way to do this?


Solution

  • Is there a better way to do this?

    You can use long division.