Bitwise Operators in C / C ++ | CPP Program to demonstrate use of bitwise operators ; a = 5 ( 00000101 ) , b = 9 ( 00001001 ) ; The result is 00000001 ; The result is 00001101 ; The result is 00001100 ; The result is 11111010 ; The result is 00010010 ; The result is 00000100
#include <iostream> NEW_LINE using namespace std ; int main ( ) { int a = 5 , b = 9 ; cout << " a ▁ = ▁ " << a << " , " << " ▁ b ▁ = ▁ " << b << endl ; cout << " a ▁ & ▁ b ▁ = ▁ " << ( a & b ) << endl ; cout << " a ▁ | ▁ b ▁ = ▁ " << ( a b ) << endl ; cout << " a ▁ ^ ▁ b ▁ = ▁ " << ( a ^ b ) << endl ; cout << " ~ ( " << a << " ) ▁ = ▁ " << ( ~ a ) << endl ; cout << " b ▁ < < ▁ 1" << " ▁ = ▁ " << ( b << 1 ) << endl ; cout << " b ▁ > > ▁ 1 ▁ " << " = ▁ " << ( b >> 1 ) << endl ; return 0 ; }