WAP to reverse the Bit by using Bitwise operators

QuestionsWAP to reverse the Bit by using Bitwise operators
Angad kadam asked 6 months ago
Please follow and like us:
1 Answers
Best Answer
AdminAdmin answered 6 months ago

#include<stdio.h>
#include<stdio.h>
main()

    int n,p,i,j,z;    
    printf(“Enter the number….\n”); 
     scanf(“%d”,&n);
     for(i=31;i>=0;i–) 
      printf(” %d “,n>>i & 1);

    for(i=31,j=0;i>j;i–,j++)
   {
       if((n>>i &1) != (n>>j &1))
       {
           n=n^1<<i;
           n= n^1<<j;
      }
   }
        printf(“reverse number is=%x\n”,n);

         for(j=31;j>=0;j–)
        printf(” %d “,n>>j & 1);
}

Please follow and like us: