|
-
March 7th, 2009, 08:15 AM
#3
Re: adding two user input arrays
For this program I have to be able to input two positive arrays up to 20 digits long and add them together, I think I have the input part right I am just having difficulty adding the two arrays together and outputting the new sum array...any help or advice would be great, here is what i have so far:
 Originally Posted by theflash
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int count = 0, number;
char first[20], second[20], sum[20];
cout << "Enter the augend: ";
cin >> noskipws >> first[0];
cout << endl;
while( first[count] != '\n')
{
count++ ;
cin >> first[count];
}
for ( number = count-1; number >= 0; number--)
cout << first[number];
cout << endl;
count=0;
cout << "Enter the adden: ";
cin >> noskipws >> second[0];
cout << endl;
while( second[count] != '\n')
{
count++;
cin >> second[count];
}
for(number = count-1; number >= 0; number--)
cout << second[number];
cout << endl;
number=0;
for(number=0;number<20;number++)
{
sum[number] = first[number] + second[number];
}
cout << sum[number];
cout << endl;
return 0;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|