
Dibyendu D. answered 12/08/19
5+ years of experience in programming and teaching C++
Dibyendu D. answered 12/08/19
5+ years of experience in programming and teaching C++
Larry C. answered 04/06/19
Computer Science and Mathematics professional
It's fairly easy, at least in C++ - just use the bitwise & (AND), | (OR) and ^ (XOR) operators.
using namespace std;
int main() {
unsigned int num1 = 10; // 10 = 0000 1010
unsigned int num2 = 12; // 12 = 0000 1100
int num3 = 0;
num3 = num1 & num2; // 8 = 0000 1000
num3 = num1 | num2; // 14 = 0000 1110
num3 = num1 ^ num2; // 6 = 0000 0110
return 0;}
Get a free answer to a quick problem.
Most questions answered within 4 hours.
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.