Summing up arrays

So the question is to let the user put in two integers and put each integer in an array as separate numbers, and then sum these arrays together, so putting in the array is not so difficult, only problem i am having is first when the user have to input the first integer, he have to put space after each number, second then I am not sure how to sum them up, so if 45676 is first array and 56717 is second, we have to start summing them up from 6 and 7 (the last numbers) do you guys have any ideas ? here is what I did for now


#include <iostream>
using namespace std;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
int main ()
{
	
	char Num1[5], Num2[5];
	int i1; int i2;

	cout << "input the first number" << endl;
	for (i1=0; i1<5; i1++)
		cin >> Num1[i1];
	for (i1=0; i1<5; i1++)
		cout << Num1[i1];
	cout << "input the second number" << endl;
	for (i2=0; i2<5; i2++)
		cin >> Num1[i2];
	for (i2=0; i2<5; i2++)
		cout << Num1[i2];
	cout << "the sum of both the arrays is" <<

}

I think that the user should enter a whole number and your task is to split it into digits and store these digits in an array.
Well it turns out it works that way even if the user does not put space in there, what is troubling me is how to add arrays together ? let's say i wanna add the first digit of the first integer with the first digit of the second integer, something like that Num1[0] + Num2[0]. This is illegal <<< , how do you do it legally in c++
You should declare a third array that will have size equal to max( sizeof( Num1 ), sizeof( Num2 ) ) + 1.
Topic archived. No new replies allowed.