Multiply function not working

I am trying to take 2 numbers that have been input into 2 arrays, and place their product into a third array.
My multiply function is way off. It is only multiplying the first pair of numbers. I am not sure where to decrement which variables to make it multiply the entire thing. I'm not sure what you need to see to know where my mistakes are, but I only have the function here...
Will someone please show me how to fix this function?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

            
//******************************************************************************
    void multiply(int num1ary[],    //Passing in num1 array,
                  int num2ary[],    //num2 array,
                  int length1,      //arrayLength1,
                  int length2)      //and arrayLength2
    {

        int counter;                //Counting numbers to process
        int i = 49;                 //Start at the end of array 1
        int j = 49;                 //Start at the end of array 2
        int k = max(length1, length2);//Finds longest number
                                    //(in case longer number isn't the top number)
        int carry = 0;              //Variable to hold carry value
        int productary[50] = {0};   //Array to hold answer
        int end = 49;               //Product array end position

        for (counter = 0; counter <= k; counter++)//While counter is less than or equal to the longest
                                                  //length of num1 or num2
            {
                //Last answer position is set to mod 10 of answer
                productary[end] = ((num1ary[i] * num2ary[j]) % 10);
                //Variable is set to previous answer/10
                carry = (num1ary[i] *  num2ary[j]) / 10;
                //Next product array position is set to value in carry
                productary[end - 1] = carry;
            }   //Fall out of loop when we have made k calculations
            for( int count = 0; count <= k; k--)//While count is less than or equal to the longest
                                                //length of num1 or num2
            {
                cout << productary[end - k];    //Display the leftmost number
                outfile << productary[end - k]; //And work your way to the left
            }   //Fall out of this loop when all calculations have been made
    }//End of function

//****************************************************************************** 


My output:
7
9
____________________________________________________
63

24
76
____________________________________________________
014

3578534
5416
____________________________________________________
00000015

2222222222222222222222222
7777777777777777777777777
____________________________________________________
00000000000000000000000014

9999999999999999999999999
9999999999999999999999999
____________________________________________________
00000000000000000000000081

8888888888888888888888888
44444444444444
____________________________________________________
00000000000000000000000032



____________________________________________________
2


In case you need it, here's the infile:

7
9
2 4
7 6
3 5 7 8 5 3 4
5 4 1 6
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
4 4 4 4 4 4 4 4 4 4 4 4 4 4

Topic archived. No new replies allowed.