C++ Bitwise Right Shift

C++ Bitwise Right Shift Operator is used to right shift a given value by specified number of bits.


The syntax for Bitwise Right Shift operation between x and y operands is

x >> y

The value of x is right shifted by y number of bits.

The operands can be of type int or char. Bitwise Right Shift operator returns a value of type same as that of the given operands.


In the following example, we take two integer values in x and y, and find the right shift of x by y number of bits.


#include <iostream>
using namespace std;

int main() {
    int x = 45;
    int y = 2;
    int result = x >> y;
    cout << "Result : " << result << endl;


Result : 11
Program ended with exit code: 0


In this C++ Tutorial, we learned what Bitwise Right Shift Operator is, its syntax, and how to use this operator in C++ programs, with the help of examples.