Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Bitwise operator in C++

#include <iostream>
using namespace std;
int main()
{
   bool a = true;
   bool b = false;
   int c = 5;
   int d = 6;
 
   cout << boolalpha;
 
   cout << "a = " << a << "; b = " << b
      << "; c = " << c << "; d = " << d;
 
   cout << "\n\nBitwise operator keywords:";
   cout << "\nc bitand d: " << ( c bitand d )<<"\tc&d:"<<(c&d);
   cout << "\nc bit_or d: " << ( c bitor d )<<"\tc|d:"<<(c|d);
   cout << "\n   c xor d: " << ( c xor d )<<"\tc^d:"<<(c^d);
   cout << "\n   compl c: " << ( compl c )<<"\t~c:"<<(~c);
   cout << "\nc and_eq d: " << ( c and_eq d )<<"\tc&=d:"<<(c&=d);
   cout << "\n c or_eq d: " << ( c or_eq d )<<"\tc|=d:"<<(c|=d);
   cout << "\nc xor_eq d: " << ( c xor_eq d )<<"\tc^=d:"<<(c^=d) ;
    cout<<"\nLogical operators";
    cout << "\n   a and a: " << ( a and a );
  cout << "\n   a and b: " << ( a and b );
     cout << "\n    a or a: " << ( a or a );
     cout << "\n    a or b: " << ( a or b );
    cout << "\n     not a: " << ( not a );
     cout << "\n     not b: " << ( not b );
     cout << "\na not_eq b: " << ( a not_eq b );
 
   return 0;
}