#include<stdio.h>
#include<stdlib.h>
int main()
{
  int i=0,j;
  int n;
  scanf("%d",&n);
  for(i=0;i<31;i++){
    if(!((1<<i) & n)){
        n=(1<<i)^n;
        break;
    }else{
        n=(1<<i)^n;
    }
  }
  printf("%d\n",n);
    return 0;
}

On Wed, Jun 23, 2010 at 9:35 PM, vijay <auvija...@gmail.com> wrote:

>  Find the next number for a given number without using any arithmetic
> operators(use bit operations)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to