#include <stdio.h>;
main() {
int input,output;
int temp;
int counter=0;
printf("\nEnter the number: ");
scanf("%d", &input);
temp=input;
while(temp) {
counter++;
temp>>=1;
}
printf("\n[debug] the length of the binary no. is : %d", counter);
output = input^(1<<(counter-1));
printf("\nThe number after unsetting the leftmost bit: %d", output);
printf("\n");
}
On Jul 23, 8:15 pm, Tech Id <[email protected]> wrote:
> Write a C function that unsets the leftmost set bit of an integer in
> less than order (n)
> n here is 32 (bit-length of an integer)
> Hint: do some bit-tricks
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.