Bit and, or and xor operations : bit « Data Type « C++






Bit and, or and xor operations

  
#include <iostream>
using namespace std;
int main()
{
 int num1, num2,iand,ior,ixor;
 cout << "Enter an integer \n";
 cin >> num1;
 cout << "Enter another integer \n";
 cin >> num2;
 iand = num1 & num2;
 ior = num1 | num2;
 ixor = num1 ^ num2;
  
 cout << num1 << " AND " << num2 << " is " << iand << endl;
 cout << num1 << " OR " << num2 << " is " << ior << endl;
 cout << num1 << " XOR " << num2 << " is " << ixor << endl;
 return 0;
}
  
    
  








Related examples in the same category