Please help!
Note: The pow() function does not seem to work in my compiler, so i have written it as a user defined function.
include
include
using namespace std;
unsigned int power(int x,int n) //substitute for pow()
{
long int p=1;
if(x==0)
{
return 0;
}
for(int i=0;i {
p=p*x;
}
return p;
}
int main()
{
unsigned int m,n,x1[5],y1[5],c1=0,c2=0;
int j; //Number N, number of trials
cin>>j;
int x[j],y[j];
for(int k=0;k{
cin>>x[k]>>y[k];
}
for(int k=0;k{
for(int i=0;x[k]!=0;i++) //Storing individual digits in an array
{
x1[i]=0;
x1[i]=x[k]%10;
x[k]=x[k]/10;
c1++; // Counter for number of digits
}
for(int i=0;y[k]!=0;i++)
{
y1[i]=0;
y1[i]=y[k]%10;
y[k]=y[k]/10;
c2++;
}
m=0;n=0;
for(int i=0;i{
m=m+(power(10,i)*x1[c1-i-1]); //Calculation of reversed number.
}
for(int i=0;i{
n=n+(power(10,i)*y1[c2-i-1]);
}
unsigned int r,a[5],c3=0;
r=m+n; //Calculation of sum
for(int i=0;r!=0;i++) //Storing the reverse of the sum
{
a[i]=r%10;
r=r/10;
c3++;
}
unsigned int t=0;
for(int i=0;i{
t=t+(power(10,i)*a[c3-i-1]); //To print the output as a number and not as a digit
}
cout<<"\n"<c1=0;c2=0;
}
return 0;
}