It seems like my old thread had died because the people helping me are now offline and no one else is repsponding so I am just gonna start this new post.
This is an assigment I recieved for one of my classes:
Write a program that reads two positive integers that are 20 or fewer digits in length and then ouputs their sum. Your program will read the digits as values of type char so that the number 1234 is read in as the four characters '1', '2', '3', '4'. After they are read into the program that characters are changed to values of type int. The digits will be read into a partially filled array, and you might find it useful to reverse the order of the elments in the array ater the data is read. Perform the addition by implementing hte usual pencil-and-paper algorithm. The result of the addition is stored in an array the same size as the input arrays and the result is written to the screen. If the result of the addition is an iteger with more than the maximum number of digits, the program should print a message saying it has encountered "integer overflow".
So far this is what I have written:
At this point I am attempting to convert the characters to integers. When I cout<Num1 [Length - 1] I get some trash number and not the actual number. Am I converting things correctly?
using namespace std;
const int Size = 20;
int main ()
char FirstNumber [Size];
char SecondNumber [Size];
int Num1 [Size];
int Num2 [Size];
cout<<"Enter the First Number : ";
cout<<"Enter the Second Number : ";
Length = strlen (FirstNumber);
Length2 = strlen (SecondNumber);
Num1 [Length] = FirstNumber [Size] - '0';
Num2 [Length2] = SecondNumber [Size] - '0';
cout<<Num1 [Length - 1];