bitwise AND in c

#include <stdio.h>

int main() {
    unsigned int a = 5;    // Binary representation: 0000 0101
    unsigned int b = 3;    // Binary representation: 0000 0011
    unsigned int result = a & b;  // Bitwise AND operation

    printf("a: %u\n", a);
    printf("b: %u\n", b);
    printf("result of a & b: %u\n", result);

    return 0;
}
  1. Declare two unsigned integers a and b with values 5 and 3, respectively.
  2. Convert the decimal values of a and b to binary representation:
  3. a binary: 0000 0101
  4. b binary: 0000 0011
  5. Apply the bitwise AND operator (&) to each pair of corresponding bits:
  6. 0 & 0 = 0
  7. 0 & 0 = 0
  8. 0 & 0 = 0
  9. 0 & 1 = 0
  10. 1 & 0 = 0
  11. 0 & 1 = 0
  12. 1 & 0 = 0
  13. 1 & 1 = 1
  14. Combine the results of the bitwise AND operation to form the binary representation of the result:
  15. Result binary: 0000 0001
  16. Convert the binary representation of the result back to decimal:
  17. Result decimal: 1
  18. Print the values of a, b, and the result of the bitwise AND operation.