Advertisement
STANAANDREY

pclab5 8

Oct 26th, 2022 (edited)
983
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.37 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void showBits(unsigned a){
  4.     int i;
  5.     for(i=sizeof(a)*8-1;i>=0;i--)
  6.         printf("%d",(a>>i)&1);
  7.     printf("\n");
  8. }
  9.  
  10. int main() {
  11.   unsigned x;
  12.   printf("x="); scanf("%u", &x);
  13.   showBits(x);
  14.   x |= (1 << 0) | (1 << 2) | (1 << 3);
  15.   x &= ~((1 << 1) | (1 << 5) | (1 << 6));
  16.   x ^= (1 << 4) ^ (1 << 7);
  17.   showBits(x);
  18.   return 0;
  19. }
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement