Module Quiz
Complete this quiz after finishing all concept and practice pages. Save your answers before opening separate quiz calibration. Treat it closed-book; check answers after finishing.
Current Module Questions
Question 1: Hex Fluency
How many bits fit in two hex digits? How many decimal values does a single byte span as unsigned?
Question 2: Two's Complement
Give the 8-bit two's-complement representation of -1 and of -128, and explain why the second is "the negative without a positive."
Question 3: IEEE 754 Decoding
Decode the 32-bit pattern 0x40490FDB as an IEEE 754 float.
Question 4: Undefined Behavior on Signed Overflow
Predict the output. What does the C standard say?
int x = INT_MAX;
if (x + 1 < x) puts("overflowed");
else puts("did not");
Question 5: Pointer Arithmetic Prediction
Predict the output on a typical x86-64 system:
int a[5] = {10, 20, 30, 40, 50};
int *p = a + 2;
printf("%d %d %d\n", *p, p[-1], *(p + 2));
Question 6: Type-Scaled Arithmetic
Given double *d; with d == 0x1000, what is the address value of d + 3? What about (char *)d + 3?
Question 7: Dangerous Cast
Predict the bytes printed on a little-endian machine:
uint32_t x = 0xAABBCCDD;
unsigned char *p = (unsigned char *)&x;
printf("%02x %02x %02x %02x\n", p[0], p[1], p[2], p[3]);
Question 8: Segment Placement
Where do each of these live (stack, heap, .data, .bss, .rodata)?
const char *msg = "hello";
int g_init = 5;
static int g_zero;
int main(void) {
int local;
int *p = malloc(4);
return 0;
}
Question 9: Stack-Frame Tracing
Briefly describe what the x86-64 function prologue push rbp; mov rbp, rsp; sub rsp, 32 does in words.
Question 10: Heap Discipline
Is there a bug in this code, and if so, what kind?
char *p = malloc(32);
if (p != NULL) strcpy(p, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJ");
free(p);
Question 11: Use-After-Free
Which line is the use-after-free?
char *s = malloc(16);
strcpy(s, "hello");
free(s);
printf("%s\n", s);
Question 12: Struct Layout Prediction
On x86-64 with default alignment, what is sizeof(struct S)?
struct S { char c; int i; char d; };
Question 13: Endianness on the Wire
On a little-endian host, uint32_t x = 0x01020304; write(fd, &x, 4);. Another machine reads the 4 bytes into its own uint32_t y with read. If that machine is big-endian, what does it see in y?
Question 14: Alignment vs Packing
What is the risk of __attribute__((packed)) on a struct with an int field followed by a double field?
Question 15: Tricky Cast and Alignment Prediction
Predict whether this compiles clean and what it prints on a typical Linux x86-64 system:
char buf[5] = { 0x78, 0x56, 0x34, 0x12, 0x00 };
uint32_t v;
memcpy(&v, buf, 4);
printf("0x%08x\n", v);
Interleaved Review Questions
Prior Module Question 1 (S1 Module 3: Probability)
What does linearity of expectation say, and why does it not require independence?
Prior Module Question 2 (S2 Module 1: Algorithm Analysis)
Solve T(n) = 2 T(n/2) + n using the Master Theorem.
Prior Module Question 3 (S3 Module 2: Software Design)
What is the core idea of the Single Responsibility Principle in one sentence?
Prior Module Question 4 (S4 Module 1: C Programming Fundamentals)
What does static mean for a file-scope variable versus a function-scope variable in C?
Prior Module Question 5 (S1 Module 1: Proof Techniques)
Prove by induction that sum_{i=1}^n i = n(n+1)/2.
Self-Assessment and Remediation
Mastery Level (90-100% correct):
- Retrieval is strong; complete all module and semester evidence gates before advancing.
Proficient Level (75-89% correct):
- Review the missed concept pages and redo two problems of each missed type. Pay particular attention to pointer-arithmetic prediction and struct layout if those were the gaps.
Developing Level (60-74% correct):
- Rework Practice 2 (pointers) and Practice 3 (memory errors / tools). Run at least three programs under ASan and at least one under Valgrind. The weakness is almost certainly under-using the tools.
Insufficient Level (<60% correct):
- Return to Cluster 1 and Cluster 2 concept pages. Most likely issue: reading pointer code without drawing memory diagrams. Restart the concept sequence with a blank paper next to you and draw every pointer before asking "what is this code doing?"
All MP1–MP6 are required independently of quiz percentage.
Progression boundary
Quiz performance calibrates retrieval and reasoning. It does not replace runnable work, changed-case transfer, the module assessment or required semester evidence. Consult practice calibration for the additional independent cases.