Answer to Question #183936 in C++ for Muhammad Zeeshan Hassan

Question #183936

Given three arrays A[n], B[n] & C[n] containing bit strings representing sets A, B & C respectively, write a code fragment to determine whether (̅∩ ) ⊂ ̅


1
Expert's answer
2021-04-22T04:48:52-0400
#include<bits/stdc++.h>
using namespace std;

//Declaring function doXor with 3 parameters
string doXor(string A, string B, int len){
string ans = "";
        
        
        for (int i = 0; i < len; i++)//for loop till the length of the variable
        {
        
                if (A[i] == B[i])// doing xor of the variables
                        ans += "0";
                else
                        ans += "1";
        }
        return ans; // returning the value of xor
}


int main()
{
        string A = "1010";
        string B = "1101";// Declaring two string with binary value
        int len = A.length();
        //storing the length of any one variable as lenghth is sae of both
        string c = doXor(A, B, len);//calling and passing argument in function 
cout <<"Xor of the two string is : "<< c << endl;//printing the value of xor 
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS