# Wa error in my programme

I am getiing wa in two test case and one test case got cleared what is wa and how can I eradicate it?

#include
#include
#include
using namespace std;
int bintodec(string n)
{
string num = n;
int dec_value = 0;

// Initializing base value to 1, i.e 2^0
int base = 1;

int len = num.length();
for (int i = len - 1; i >= 0; i--) {
if (num[i] == '1')
dec_value += base;
base = base * 2;
}

return dec_value;

}
int main() {
int f;
cin>>f;
while(f!=0)
{
string a,b;
cin>>a>>b;
int count=0;
int c=bintodec(a);
int d=bintodec(b);
while(d!=0)
{
int u=c^d;
int v=c&d;
c=u;
d=v*2;
count+=1;
}
cout<<count<<endl;
fโ;
}
// your code goes here
return 0;
}

Please either format your code or link to your submission - the forum software has mangled it and it wonโt compile!

Also - what Problem are you trying to solve?

problem
my solution
#include
#include
#include
using namespace std;
int bintodec(string n)
{
string num = n;
int dec_value = 0;

int base = 1;

int len = num.length();
for (int i = len - 1; i >= 0; i--) {
if (num[i] == '1')
dec_value += base;
base = base * 2;
}

return dec_value;

}
int main() {
int f;
cin>>f;
while(f!=0)
{
string a,b;
cin>>a>>b;
int count=0;
int c=bintodec(a);
int d=bintodec(b);
while(d!=0)
{
int u=c^d;
int v=c&d;
c=u;
d=v*2;
count+=1;
}
cout<<count<<endl;
fโ;
}
// your code goes here
return 0;
}

You can have a string much more then sizeof(int)*8 at first. Really, the constrains are |A|,|B|โค500.

thanks vitaly so basically can you help me with code?? I am not able to make it

when you are trying to convert the binary string to decimal it genarating value which is greater than INT_MAX. So, data overflow occurred in your code.
Have you read the editorial ?
If not go through it link: BINADD - Editorial