Bitwise operators are used to process numbers with respect to their binary representation. The main task of bitwise operators is to manipulate binary values bitwise.

The operations are directly supported by the processor. Bitwise operations are required for working with device drivers, low-level graphics, cryptography, and network communication.

~Bit complement
<<Left shift of bit patterns
>>Right shift of bit patterns
&Bitwise AND
^Bitwise XOR
|Bitwise OR

Code Explanation

5Declares the integer variables x, y, z, a, b, c.
x, y and z are not initialized.
The variable a is initialized with the value 7,
b with the value 12 and
c with the value 15.
6Bitwise AND linking of the two variables a and b
7Bitwise OR linking of the two variables a and b
8Bitwise XOR linking of the two variables a and b
9 – 11Outputs the result of the bit operators
#include &lt;iostream&gt;
using namespace std;

int main() {
	int x, y, z, a=7, b=12, c=15;
	x = a & b;
	z = a | b;
	y = a ^ c;
	cout << "Bitwise AND: " << x << endl;
	cout << "Bitwise OR: " << z << endl;
	cout << "Bitwise XOR: " << y << endl;