
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Bitwise Operators in C
Bitwise operators are used to perform bit-level operations on two variables. Here is the table of bitwise operators in C language,
Operators | Name of Operators |
---|---|
& | Bitwise AND |
| | Bitwise OR |
^ | Bitwise XOR |
~ | Bitwise complement |
<< | Shift left |
>> | Shift right |
Here is an example of bitwise operators in C language,
Example
#include <stdio.h> int main() { int x = 10; int y = 28; int i = 0; printf("Bitwise AND : %d\n", x&y); printf("Bitwise OR : %d\n", x|y); printf("Bitwise XOR : %d\n", x^y); printf("Bitwise Complement : %d,%d\n", ~x,~-y); for(i;i<2;i++) printf("Right shift by %d: %d\n", i, x>>i); for(i;i<=3;++i) printf("Left shift by %d: %d\n", i, y<<i); return 0; }
Output
Bitwise AND : 8 Bitwise OR : 30 Bitwise XOR : 22 Bitwise Complement : -11,27 Right shift by 0: 10 Right shift by 1: 5 Left shift by 2: 112 Left shift by 3: 224
- Related Questions & Answers
- Bitwise Operators in C++
- Bitwise right shift operators in C#
- What are bitwise operators in C#?
- Java Bitwise Operators
- Perl Bitwise Operators
- Python Bitwise Operators
- C# Bitwise and Bit Shift Operators
- Bitwise operators in Dart Programming
- What are JavaScript Bitwise Operators?
- Explain about bitwise operators in JavaScript?
- C++ Program to Perform Addition Operation Using Bitwise Operators
- What are the bitwise operators in Java?
- What are different bitwise operators types in Python?
- What are the differences between bitwise and logical AND operators in C/C++
- How to multiply a given number by 2 using Bitwise Operators in C#?
Advertisements