
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
What is Bitwise OR in C++?
The bitwise OR operator (|) compares each bit of first operand to the corresponding bit of second operand. If either bit is 1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0. Both operands to the bitwise inclusive OR operator must be of integral types. For example,
Example
#include <iostream> using namespace std; int main() { unsigned short a = 0x5555; // pattern 0101 ... unsigned short b = 0xAAAA; // pattern 1010 ... cout << hex << ( a | b ) << endl; }
Output
This gives the output −
ffff
- Related Articles
- What is Bitwise OR Operator (|) in JavaScript?
- What is JavaScript Bitwise OR (|) Operator?
- What is Bitwise OR Assignment Operator (|=) in JavaScript?
- What is Bitwise XOR in C++?
- What is Bitwise AND in C++?
- Find subsequences with maximum Bitwise AND and Bitwise OR in Python
- Bitwise OR (or - ) of a range in C++
- Bitwise AND and OR in Arduino
- What is Bitwise AND Operator (&) in JavaScript?
- What is Bitwise NOT Operator (~) in JavaScript?
- What is Bitwise XOR Operator (^) in JavaScript?
- What is JavaScript Bitwise AND (&) Operator?
- What is JavaScript Bitwise NOT(~) Operator?
- What is JavaScript Bitwise XOR (^) Operator?
- What is JavaScript Bitwise Left Shift(

Advertisements