Replace the Bit
Submissions: 3697   Accuracy:

44.12%

  Difficulty: Basic   Marks: 1

Given two numbers n and k, change the kth bit of the number n to '0' if it is  '1', else return the number n itself.

Input:
First line of the input contains an intger T denoting the number of test case. Each test contains a single line containg two space seperated integers n and k respectively.

Output:
For each test case output a single integer.

Constraints:
1<=T<=100
1<=N<=106

Example:
Input:
2
13 3
13 2
Output:
13
9

Explanation:

Test Case 1: n = 13 ('1101') k=3
return 13

Test Case 2: n = 13('1101') k=2
return 9('1001')

** For More Input/Output Examples Use 'Expected Output' option **

Author: harshitsidhwa


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.