003-005-006
Bitwise Operator: Even or Odd Check
Easy
Problem Description
Bitwise operator: Even or Odd Check
In this problem, you will create a program that reads an integer n from standard input, performs a bitwise AND operation (&) between n and 1, and displays the result to standard output.
Learning Objective: Learn simple checking using bitwise AND operator
Overview
Let's learn the most commonly used AND operator (&) among bitwise operators. By AND-ing a number with 1, you can easily determine if it's even or odd!
Input
- Line 1: integer
n
Output Format
n & 1 = result
Example
Input: 7
Output: 7 & 1 = 1
Hint
The result is 1 for odd numbers, 0 for even numbers.
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up