Code
#include <string>
#include <iostream>
using namespace std;
void add(string a,string b,char sum[],int& count)
{
int len1=a.length();
int len2=b.length();
int i=len1-1,j=len2-1,temp=0,carry=0;
count=0;
while(i>=0&&j>=0)
{
temp=a[i]-'0'+b[j]-'0'+carry;
sum[count++]=temp%10+'0';
carry=temp/10;
--i;
--j;
}
while(i>=0)
{
temp=a[i]-'0'+carry;
sum[count++]=temp%10+'0';
carry=temp/10;
--i;
}
while(j>=0)
{
temp=b[j]-'0'+carry;
sum[count++]=temp%10+'0';
carry=temp/10;
--j;
}
if(carry>0)
{
sum[count++]='1';
}
}
void print(char arr[],int len)
{
int i;
for(i=len-1;i>=0;--i)
{
cout<<arr[i];
}
cout<<endl;
}
int main()
{
string a,b;
char sum[2000];
int count,cs;
cin>>count;
for(cs=1;cs<=count;cs++)
{
int len;
cin>>a>>b;
cout<<"Case "<<cs<<":"<<endl;
cout<<a<<" + "<<b<<" = ";
add(a,b,sum,len);
print(sum,len);
if(cs!=count)
cout<<endl;
}
return 0;
}