By using the concept of filling all the bits by 1 using shift operation.
---------------------------------------------------------------------
#include<stdio.h>
int main()
{
unsigned int n =1;
n |= n >> 1;
n |= n >> 4;
n |= n >> 8;
n |= n >> 16;
n++;
printf("\nn=%d\n",n);
return 0;
}
No comments:
Post a Comment