If we do the same question by storing the ans in the third string ,it is not giving any output

#include
#include
using namespace std;

int main()
{
int test;
cin>>test;
while(test–)
{
string s[3];
for(int i=0;i<2;i++)
{ cin>>s[i];}

	for(int i=0;i<s[0].length();i++)
	{
		s[3][i]=((s[1][i]-'0')^(s[0][i]-'0'))+'0';
		//cout<<" "<<s[4][i]<<" ";
		}	
	//cout<<s[4 ][0];
	cout<<s[2]<<endl;
	
}

}

Hey @Nidhi_Alipuria the problem is that you are not storing the answer correctly

  1. you should store it in s[2] not s[3]
  2. you should use s[2] += instead of s[2][i] = because there is no i’th character in s[2] to replace with

So replace
s[3][i]=((s[1][i]-‘0’)^(s[0][i]-‘0’))+‘0’;
by
s[2]+=((s[1][i]-‘0’)^(s[0][i]-‘0’))+‘0’;

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.