```
My logic is that the problem can be broken down into four cases according to the the two numbers that is entered;
both numbers are strictly greater than 10 let us call them j and k , suppose the number are 812 + 199, so according to the question the answer
will be 901 , which my program successfully calculates by the logic;
divide the number1 i.e 812/10 = 80 and stores it as d1 i.e. d1-->812/10;
similarly d2-->199/10 ie 9;
similarly store the remainders r1 and r2 of operation d1 and d2 respectively which would be
r1--->12 r2--->9;
Now if r1+r2 is greater than 10 subtract 10 from them as their carried value while normal addition is to pe ignored as per the question and proceed to store it in temp;
and if r1+r2 is lesser than than simply store it in temp variable;
the final buggy sum would be sum = (d1+d2-10)*10+temp;
Similar logic is applied in all the cases namely if let two variable to be calculate j and k
j>10 k>10
1=<j,k<=10
j>10 k<10
j<10 k>10
All the values are exactly calculated according to the question
But the problem occurs when adding number like 988 + 122;
the two values of both the number from left side are rightly calculated but leftmost side of both the numbers that are 9 and 1 are calculated
as 10 rather than 0
I am unable to write a logic for that , can anyone suggest something ?
```

```
#include<iostream>
using namespace std;
int main()
{
int test_cases = 0;
int j , k = 0;
int d1 , d2 ,r1 ,r2;
int temp = 0;
int sum = 0;
cin>>test_cases;
while(test_cases--)
{
cin>>j>>k;
if(j>10&&k>10)
{
d1 = j/10;
d2 = k/10;
r1 = j%10;
r2 = k%10;
if(d1+d2>10)
sum += (d1+d2-10)*10;
if(r1+r2<10)
sum += r1+r2;
else{
temp = r1+r2-10;
sum += temp;
}
}
if(j>=1&&j<10&&k>=1&&k<10)
{
if(j+k>=10)
sum += j+k - 10;
else
sum += (j+k);
}
if(j>10&&k<10)
{
d1 = j/10;
r1 = j%10;
sum += d1*10;
temp = r1+k;
if(temp<10)
sum += temp;
if(temp>=10){
temp = temp-10;
sum +=temp;
}
}
if(k>10&&j<10)
{
d1 = k/10;
r1 = k%10;
sum += d1*10;
temp = r1+j;
if(temp<10)
sum += temp;
if(temp>=10){
temp = temp-10;
sum +=temp;
}
}
cout<<sum;
cout<<endl;
sum=0;
temp=0;
}
}
```