Shift statement in for : Bit Shift « Data Type « C / ANSI-C






Shift statement in for


#include <stdio.h>

int main(void)
{
  unsigned u = 100;

  int n;

  for(n = 32768; n; n = n >> 1)
    if(u & n) 
        printf("1 ");
    else 
        printf("0 ");

  printf("\n");

  return 0;
}


           
       








Related examples in the same category

1.A bit shift exampleA bit shift example
2.Shift bitwise and display the resultShift bitwise and display the result
3.Use bit shift to calculate