Multiplying Binary Arrays

Hi, I am required to multiply and add binary arrays for an assignment. Originally I had it set where I convert the binary array to a decimal number, multiply the numbers and then reconvert them, but my professor is not looking for that. She wants us to use for loops. I am stuck I have been for a while. A nudge in the right direction will help. Here is my code so far. My addition is working fine, its just my multiplication function that's suffering.

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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
  void addition(int b1[10], int b2[10])
{
	int sum[11];
	int remainder = 0;

	for (int i = 10; i >= 0; i--)
	{
		if (b1[i] + b2[i] + remainder >= 2)
		{
			sum[i] = b1[i] + b2[i] + remainder;
			sum[i] = sum[i] % 2;
			remainder = 1;
		}
		else
		{
			sum[i] = b1[i] + b2[i] + remainder;
			remainder = 0;
		}
	}

	for (int j = 0; j < 10; j++)
	{
		cout << sum[j];
	}
}

void multiplication(int m1[10], int m2[10])
{
	int sum[11];
	int temp[10] = { 0 };
	int x = 0;

	for (int i = 10; i >= 0; i--)
	{
		for (int j = 10; j >= 0; j--)
		{
			temp[i] += m1[j];

			if (temp == 0)
			{
				sum[i] = 0;
				break;
			}
			else
			{
				sum[i] += temp;
			}
		}

		addition(sum, m2);
	}
}


In my main I have my binary values declared and initialized, I also am calling the functions from the main function. Thank you for any help.
Topic archived. No new replies allowed.