Bitwise operators in c++

Problem

Write a C++ function that takes a character as input and returns true if the second significant bit of the binary representation of the character is set (i.e equals to 1) otherwise return false.

Bitwise operators

Solution

This is a bitwise operations problem. First you need to shift the character one digit to the right then do an AND operation between the character and the constant (1)

c++ bitwise operators example

Here is a bitwise c++ example

Please use the comments section below for questions or feedback. Thanks for visiting.

Tags:

Add a Comment

Your email address will not be published. Required fields are marked *