17 . xor properties

 

/*  properties:

      1. A^0 = A

      2. A^A = 0  //equality check

      3. A^B = B^A

      4. A+B = (A^B) + 2*(A&B)

   */

Code :

#include<bits/stdc++.h>

using namespace std;

int main()

{   

    cout<<"xor properties:\n";

    int t,n,i;

    cin>>t;

    while (t--)

    {

        cin>>n>>i;

        cout<<"xor:"<<(n^i)<<endl;

    }

}




Comments