Page 1 of 1

## 1 Replies - 1164 Views - Last Post: 11 September 2007 - 05:58 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=33073&amp;s=39221b18416460c03ef4e1c328732351&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 bortiz0823

Reputation: 0
• Posts: 21
• Joined: 28-January 07

Posted 11 September 2007 - 05:57 PM

hi guys, I have already the conversion of CHAR to INT. I made the code to show the 2 numbers of 20 digits, but I have no idea how can I add this two numbers. I have to use a loop?? Here is the code and any idea are welcome.
```//Solo muestra mis 2 numeros de 20 digitos
//Solo falta sumarlos

#include <iostream>
#include <cstdlib>
using namespace std;

int Sum(char A[20])
{
char aa;
int num1[ 20 ];

for( int ii = 0; ii < 20; ii++ )
{
aa = A[ ii ]; //Conversion
num1[ ii ] = atoi( &aa ); //Conversion
}
cout << "\n\n ";
for( int ii = 0; ii < 20; ii++ )
{
cout << num1[ ii ];

}

}

int Sum2(char B[20])
{
char bb;
int num2[ 20 ];

for( int ii = 0; ii < 20; ii++ )
{
bb = B[ ii ]; //Conversion
num2[ ii ] = atoi( &bb ); //Conversion

}
cout << "\n+";
for( int ii = 0; ii < 20; ii++ )
{
cout << num2[ ii ];

}
cout<<"\n---------------------\n";
}

int main()
{

char numA[ 20 ];
char numB[ 20 ];

cout<<"Entre un numero de 20 digitos: ";
cin>>numA;
cout<<"\nEntre otro numero de 20 digitos: ";
cin>>numB;
Sum(numA);
Sum2(numB);

cout<<"\n";
system("pause");
return 0;

}

```

Is This A Good Question/Topic? 0

### #2 skyhawk133

Reputation: 1960
• Posts: 20,409
• Joined: 17-March 01