luc104.c ​
Metadata ​
- Author — Amit Dutta
- Last updated — 08 Feb 2026
- License — MIT License (See the LICENSE file for details)
Problem Statement ​
Problem Statement
Rewrite expressions using bitwise compound assignment operators.
Source Code ​
Printing the code
To print this file, open it on GitHub and click Raw before printing, or use the Download Raw button above and print directly from that page.
c
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a = 10, b = 20, c = 5;
printf("Original values: a=%d, b=%d, c=%d\n", a, b, c);
// a = a | 3
a |= 3;
printf("a |= 3 -> %d\n", a);
// a = a & 0x48
a &= 0x48;
printf("a &= 0x48 -> %d\n", a);
// b = b ^ 0x22
b ^= 0x22;
printf("b ^= 0x22 -> %d\n", b);
// c = c << 2
c <<= 2;
printf("c <<= 2 -> %d\n", c);
return 0;
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27