Advertisement
Imran_Mohammed

Bitwise Operator

Jan 5th, 2022
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. main() {
  5.  
  6.    int a,b;
  7.    cin >> a >> b;
  8.  
  9.    int c = a&b;
  10.    cout << "The output of the Bitwise AND operator is: " << c << endl ;
  11.  
  12.    int d = a|b;
  13.    cout << "The output of the Bitwise OR operator is: " << d << endl ;
  14.  
  15.    int e = a^b;
  16.    cout << "The output of the Bitwise Exclusive OR operator is: " << e << endl ;
  17.  
  18.    int f = ~a;
  19.    cout << "The output of the Bitwise Exclusive Negation operator is: " << f << endl ;
  20.  
  21.    int g = a << 2;
  22.    cout << "The output of the Bitwise Left Shift operator is: " << g << endl ;
  23.  
  24.    int h = a >> 2;
  25.    cout << "The output of the Bitwise Right shift operator is: " << h << endl ;
  26.  
  27.    return 0;
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement