Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

bitwise operators in c++,c

#include <iostream>
using namespace std;

int main() {
    // Bitwise and & , bitwise or | , bitwise XOR ^
    // (10)10=(1010)2 ,(15)10=(1111)2
	int x = 10 & 15; // 1010
	int y = 10 | 15; // 1111
	int z = 10 ^ 15; // 0101
	cout << x <<endl;
	cout << y <<endl;
	cout << z <<endl;
	
	/* and & ,  or | ,  XOR ^
	   00 0		00 0	00 0 
	   01 0		01 1	01 1
	   10 0 	10 1	10 1
	   11 1		11 1	11 0 */
}
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #bitwise #operators
ADD COMMENT
Topic
Name
3+5 =