Multiplying two integer arrays

I'm writing a C++ program where I have two arrays (firstNum and secondNum) which store two separate large numbers with each array space storing one digit. The numbers can be up to 72 digits in length and so each array is of length 72 with the numbers stored from right to left (meaning firstNum[71] would store a 3 if the number was 4543 and every other space would to the left of the first digit would be a zero).

976854 = firstNum = {.....0,0,0,0,0,9,7,6,8,5,4} //with firstNum[71]=4
89968 = secondNum = {....0,0,0,0,0,8,9,9,6,8}

and the answer would be stored in a final array as such:
967854*89968 = 87075888672

finalNum = {....0,0,0,0,0,0,0,8,7,0,7,5,8,8,8,6,7,2}

My program already asks the user to enter both numbers and stores them in two separate arrays in the right to left format with every empty space being 0. Now I need to actually multiply them and store the results in the finalNum array. I believe this can be done with a nested loop but I haven't been able to figure out how. (I've got the addition function working without issue using the same arrays).

I'll post my current source below, it compiles but does not provide the correct result. Please look over.
int carry=0;
int prod,i,j,rem;
int base=10;

else if ( op == '*' ) //checks for operator, performs array multiplication
{
for(i=size-1; i>-1;i--)
{
for(int j=size-1; j>-1;j--)
{
prod =firNum[i]*secNum[j];
prod += carry;

if(prod>=base)
{
carry = (prod/base);
prod -= (carry*base);
}

else
{
carry = 0;
final[i+j] += prod;

if(final[i+j] >= base)
{
rem = (final[i+j]/base);
final[i+j] -= rem*base;
carry += rem;
}
if(final[i+j] >= base)
{
final[i+j-1] += (final[i+j]/base);
final[i+j] = final[i+j] % base;
}
}
}
}
}
Topic archived. No new replies allowed.