Question: Security System You are working on a security system that uses a binary key to unlock a vault. The key consists of a series of

Security System
You are working on a security system that uses a binary key to unlock a vault. The key consists of a series of bits, each representing a specific function of the security system.
You are given an integer value N, which represents the curfent binary key configuration gor and an integer value B, which represents the bit position that needs to be toggled to
activate the security feature.
a Your task is to find and return an integer value representing the updated binary key configuration after toggling the Nth bit to activate the security feature.
Note: Toggling a bit means changing it from 0 to 1 or from 1 to 0.
Input Specification:
input1: An integer value N, representing the current binary key configuration input2: An integer value B, representing the bit position to toggle for activating the security feature
Output Specification:
Return an integer value representing the updated binary key configuration after toggling the Nih bit to activate the security feature.
Example 1:
input1: 37
input2: 3
Output : 45
Explanation:
Here, N =37 and B =3. The binary representation of 37 is 100101. Toggling the 3rd bit
results in 101101, which is equivalent to 45 in decimA notation. Hence, 45 is returned as the output.
Example 2: input1: 15
input2: 2
Output : 11
Explanation:
Here, N =15 and B =2. The binary representation of 15 is 1111. Toggling the 2nd bit
results in 1011, which is equivalent to 11 in decimal notation. Hence, 11 is returned as the output.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!