Systems programming · Quick practice
Make the basics automatic.
One small question. Check it. Do another. Fresh numbers, as long as you want.
Changing a setting starts a fresh round; missed questions stay available.
Choose the number bases for bit operations
Applies to bitwise operations, pattern shifts, and masks. Conversions and C expressions use their own stated formats. Decimal pattern results are unsigned.
Question 1
Round complete
Quick reference & assumptions
Work through every value
Lock onto one conversion, signed representation, or char skill. Each 8-bit pass shows all 256 patterns once in scrambled order: unsigned 0…255 or signed −128…127. One-digit hex passes cover 0…F. Then another pass begins.
Pass progress counts questions shown; review missed questions to correct mistakes. Settings, pass positions, and missed questions are saved in this browser when storage is available. Round scores start fresh. Mixed modes rotate through skills.
Pointer basics
With int x = 7; int *p = &x;, p holds the address of x and *p reads 7. Writing *p = 9; changes x to 9. Array indices start at 0.
The pointer drills use valid objects and one dereference at a time. The type-size drill assumes that object pointers occupy 8 bytes.
Bit weights
From left to right in 8 bits:
128 64 32 16 8 4 2 1For two’s complement, the first weight becomes −128. A leading 1 means negative. For 8-bit values: unsigned 0…255; signed −128…127.
To negate a fixed-width pattern: invert every bit, then add 1. Keep only the chosen width.
Hex ↔ four bits
| Hex | Binary | Hex | Binary |
|---|---|---|---|
| 0 | 0000 | 8 | 1000 |
| 1 | 0001 | 9 | 1001 |
| 2 | 0010 | A | 1010 |
| 3 | 0011 | B | 1011 |
| 4 | 0100 | C | 1100 |
| 5 | 0101 | D | 1101 |
| 6 | 0110 | E | 1110 |
| 7 | 0111 | F | 1111 |
Practice machine
| Type | Bytes | Bits |
|---|---|---|
| char | 1 | 8 |
| short | 2 | 16 |
| int | 4 | 32 |
| long / long long | 8 | 64 |
| float | 4 | 32 |
| double | 8 | 64 |
| Object pointers | 8 | 64 |
Signed and unsigned versions have the same storage size. These are practice assumptions, not universal C sizes. Integer sizes match the Timberlea examples in Lecture 5. C fact questions explicitly ask about C itself.
Keep the operations separate
& | ^ ~ act on bits. && || ! act on truth and return 0 or 1. Zero is false; any nonzero integer is true.
Bit-pattern questions use exactly the displayed width. A logical right shift fills with 0; an arithmetic right shift copies the sign bit.
C expressions use C17 and 32-bit int/unsigned int. C promotes small integer operands before shifting or complementing. Negative signed right shift is implementation-defined in C17; signed overflow is undefined. The fixed-width exercises specify their own bit operations.
Rule reference: WG14 C draft, §§6.3.1.1, 6.5.3.3–4 and 6.5.7–14; the relevant rules also apply in C17.