In this tutorial, you shall learn about Equal-to Relational Operator in C++ programming language, its syntax, and how to use this operator with the help of examples.
C++ Bitwise Right Shift
C++ Bitwise Right Shift Operator is used to right shift a given value by specified number of bits.
Syntax
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.
Examples
1. Bitwise right shift of x=45 by 2 bits
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.
main.cpp
#include <iostream>
using namespace std;
int main() {
int x = 45;
int y = 2;
int result = x >> y;
cout << "Result : " << result << endl;
}
Output
Result : 11
Program ended with exit code: 0
Conclusion
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.