Skip to main content

Problem Statement

Print the result of bitwise AND and OR of two numbers.

Solution

#include <stdio.h>

int main() {
    int a = 6, b = 3;  // 110 & 011
    printf("AND: %d\n", a & b);  // 010 = 2
    printf("OR : %d\n", a | b);  // 111 = 7
    return 0;
}

Output

AND: 2
OR : 7