luc104.c (693B)
1 /* Rewrite expressions using bitwise compound assignment operators. 2 */ 3 /* Let Us C, Chap- 21 (Operations on Bits), Qn No.: B(b) */ 4 5 /* This file is auto-generated by a bot. */ 6 /* This code is not compiled; it is for reference only. */ 7 8 9 #include <stdio.h> 10 #include <stdlib.h> 11 12 int main() 13 { 14 int a = 10, b = 20, c = 5; 15 16 printf("Original values: a=%d, b=%d, c=%d\n", a, b, c); 17 18 // a = a | 3 19 a |= 3; 20 printf("a |= 3 -> %d\n", a); 21 22 // a = a & 0x48 23 a &= 0x48; 24 printf("a &= 0x48 -> %d\n", a); 25 26 // b = b ^ 0x22 27 b ^= 0x22; 28 printf("b ^= 0x22 -> %d\n", b); 29 30 // c = c << 2 31 c <<= 2; 32 printf("c <<= 2 -> %d\n", c); 33 34 return 0; 35 }