MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / main

Function main

CPP/bitmasking/bit-comms.cpp:9–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7#define endl '\n'
8
9int main(){
10 cin.tie(0)->sync_with_stdio(0);
11 int a;
12 a=5;
13 int b;
14 b=10;
15 cout<<a<<" and "<<b<<" is "<<(a&b)<<endl;//bitwise and - when both the bits are true then return true
16 cout<<a<<" or "<<b<< " is "<<(a|b)<<endl;//bitwise or - when anyone of the bit is true then returs 1
17 cout<<a<<" xor "<<b<<" is "<<(a^b)<<endl;//bitwise xor - when both the bits are same then returns 0
18
19 //bitwise complement operator
20 cout<<"~( a) is "<<~(a)<<endl;
21
22 //left and right shift operator
23 a=5;
24 b=2;
25 cout<<"left shift = "<<(a<<b)<<endl;
26 //left shift all the bits by the factor of b [=a*2^b]
27 //right shift all the bits by the faccor of b [=a/2^b]
28 cout<<"right shift = "<<(a>>b)<<endl;
29
30 return 0;
31}
32
33

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected