Well im having this problem on how to add large integers. I have used strings to take in a very large number something that can work on as many digits as you need it to. I take in 2 strings for the numbers you want to add. After which I convert the strings to int arrays by reading the ascii value and then subtracting 48 to get the actual number value.
All up to that point works fine. The part im having trouble is the for loop that adds each number at a time starting from the end of each for loop then determining the carry value and sum. Then put the number back into another array called total which will be used to print out the result.
So far i have tried so many different tweaks and remaking this code nothing works. Please help me! Im about to pull my hair out. By the way this is my first time on this forum so excuse my mistakes.
for(int x=strl1; x>=0; x--){
sum=num2[x]+num1[x]+carry;
carry=sum-10;
if(carry<=0){
carry=0;
sum=10%sum;
}
total[x]=sum;
}
for(int i=0; i<strl1+1; i++){
cout<<total[i];
}
I think this might be all you need but if not let me know ill post more of it. But this is the part that is not working right. I know im close and that there is something small that is messing me up. Thanks for the help in advance.