Change all even bits in a number to 0
Basic Accuracy: 66.83% Submissions: 3994 Points: 1

Given a number N, change all bits at even positions to 0.

Example 1:

Input: N = 30
Output: 10 
Explanation: Binary representation of 
11110. Bits at Even positions are 
highlighted. After making all of them 
0, we get 01010. Hence the answer is 10.

Example 2:

Input:  N = 10
Output: 10
Explanation: Binary representation of 
1010. Bits at Even positions are 
highlighted. After making all of them 
0, we get 1010. Hence the answer is 10.


Your Task:  
You dont need to read input or print anything. Complete the function convertEvenBitToZero() which takes n as input parameter and returns the value of N after changing bits at even positions.

Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)

Constraints:
1<= N <=(32-bit number)

We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.


to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Change all even bits in a number to 0

Output Window