Program to Turn off the rightmost set bit

C function that unsets the rightmost set bit of an integer. Examples: Input: 10 (00…01010) Output: 8 (00…01000) Input: 7 (00…00111) Output: 6 (00…00110) Let the input number be n. new balance 420 femme beige n-1 would have all the bits flipped after the rightmost set bit (including the set bit). new balance 1980 zante roma So, Angel Pagan Jersey doing n&(n-1) would give us the required result. nike air max 2017 mujer Algorithm :

 int fun(unsigned int n) { return n&(n-1); } int main() { int n = 7; printf("The number after unsetting the rightmost set bit %d", 

Leave a Reply

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

For Inserting code :
Paste your code in the comment form, select it and then click the language link

C | C++ | Java |

*