003-005-009

Bitwise Operators: Binary Logical Operations

Medium

Problem Description

Bitwise Operators: Binary Logical Operations

Learning Objective: Understand how bitwise operators (&, |, ^) work in logical operations

Overview

Create a program that receives two integers as input and outputs the results of bitwise AND, OR, and XOR operations.

Specifications

  • Read the first integer from the first line
  • Read the second integer from the second line
  • Output the result of bitwise AND operation (&)
  • Output the result of bitwise OR operation (|)
  • Output the result of bitwise XOR operation (^)
  • Output each result in the format "[operation name]: [result]"

Input Format

12
10

Output Format

AND: 8
OR: 14
XOR: 6

Note

Binary representation of 12: 1100
Binary representation of 10: 1010

  • AND (1100 & 1010 = 1000 = 8)
  • OR (1100 | 1010 = 1110 = 14)
  • XOR (1100 ^ 1010 = 0110 = 6)

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?