Given a non-negative number N and two values L and R. The problem is to set all the bits in the range L to R in the binary representation of N.
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains three integers N, L and R as input.
For each test case, set the bits in given range and print the modified number in new line.
17 2 3
8 1 2
Input : N = 17, L = 2, R = 3 Output : 23 (17)10 = (10001)2 (23)10 = (10111)2 The bits in the range 2 to 3 in the binary representation of 17 are set.
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.