#include
#include
using namespace std;
int compare(string s1 , string s2)
{
int i = 0;
while(i < s1.length())
{
if(s1[i] == s2[i])
s1[i] = ‘0’;
else
s1[i] = ‘1’;
i++;
}
cout<<s1;
}
int main()
{
int ts;
cin>>ts;
while(ts > 0)
{
string s1;
string s2;
cin>>s1>>s2;
compare(s1,s2);
ts–;
}
}
Why the code is showing error?
- Change line 15 to cout<<s1<<endl; You have missed endl
- Change return type to compare function to void
@dhruvtrehan45
I think you got the mistake and successfully submitted the code. Please mark this doubt as resolved.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.