Bitwise Operators | Practice | GeeksforGeeks

Bitwise operators are useful when we want to work with bits. Here, we'll take a look at them.
Given three positive integers a, b and c. Your task is to perform some bitwise operations on them as given below:1. d = a ^ a2. e = c ^ b3. f = a & b4. g = c | (a ^ a)5. e = ~eNote: ^ is for xor. The working of bitwise operators can be found here.
Example:
Input:a = 4b = 8c = 2Output:01002-11
Constraints:1 <= A, B, C <= 106
Video:
YouTubeGeeksforGeeks500K subscribersC++ Programming Language Tutorial | Operators in C / C++ | GeeksforGeeksWatch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.Full screen is unavailable. Learn MoreMore videosMore videosYou're signed outVideos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer.CancelConfirmSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:000:00 / 3:16•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=WFy9SFJsAWQ" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>
0
sahibealam293 months ago
void bitWiseOperation(int a, int b, int c) {   int l1=a^a,l2=c^b,l3=a&b,l4=c|l1,l5=~l2;   cout<<l1<<endl<<l2<<endl<<l3<<endl<<l4<<endl<<l5<<endl;   // Your code here}
0
sahibealam293 months ago
use endl or "\n" at end so 0 will not add at end of output
0
swnkhurana6 months ago
void bitWiseOperation(int a, int b, int c) {
int d = a^a;int e = c^b;int f = a&b;int g = c | (a^a);int h= ~e ;cout<<d<<endl<<e<<endl<<f<<endl<<g<<endl<< h <<endl;
   // Your code here}
0
yogeshwari harode11 months ago
yogeshwari harode
Bitwise Operators (Simple way to solve)https://github.com/yogeshwa...
0
yogeshwari harode11 months ago
yogeshwari harode
Bitwise Operators (Simple way to solve)https://github.com/yogeshwa...
0
SACHIN KUMAR1 year ago
SACHIN KUMAR
void bitWiseOperation(int a, int b, int c){
    int d = a^a;    int e = c^b;    int j=e;    int f = a&b;    int g = c | (a^a);     e = ~e;    cout<<d<<endl<<j<<endl<<f<<endl<<g<<endl<<e<<endl; }="">
0
preet gandhi2 years ago
preet gandhi
Test Case:- 324 435 192Actual O/P:- 0371256192-372My O/P :- 0371256448
code:-int e=a&b;    int d=c|e;    int f=c^b;    // Your code here    cout<< int(a^a) <<endl; cout<<="" f="" <<endl;="" cout<<="" e="" <<endl;="" cout<<="" d="" <<endl;="" cout<<="" ~f<<endl;="">
0
aditya jha2 years ago
aditya jha
int d = a ^ a;int e = c ^ b;int f = a & b;int g = c | (a ^ a);int h= ~e;cout<
0
h3 h32 years ago
h3 h3
0
ANKIT SAHU2 years ago
ANKIT SAHU
https://ide.geeksforgeeks.o...
We strongly recommend solving this problem on your own before viewing its editorial. Do you still
                    want to view the editorial?
 Login to access your submissions. 

Problem


Contest

Reset the IDE using the second button on the top right corner.
Avoid using static/global variables in your code as your code is tested against multiple test cases and these tend to retain their previous values.
Passing the Sample/Custom Test cases does not guarantee the correctness of code. On submission, your code is tested against multiple test cases consisting of all possible corner cases and stress constraints.
You can access the hints to get an idea about what is expected of you as well as the final solution code.
You can view the solutions submitted by other users from the submission tab.