{
  "schemaVersion": 1,
  "code": "CSCI 2122",
  "title": "Midterm Review",
  "description": "One question from each of the 21 sample-test types: 18 multiple-choice questions, a two-part memory trace, and two C implementations.",
  "source": {
    "filename": "SampleQuestionsF26.pdf",
    "title": "CSCI 2122 Practice Questions for Mid-Term",
    "pages": 5,
    "answerKeyProvided": false,
    "attribution": "Dalhousie University Faculty of Computer Science",
    "note": "Original questions and choices are transcribed from the supplied PDF. Answer keys, explanations, clarifications, and new variants were created for this review; they are not an official instructor answer key."
  },
  "assumptions": [
    "Use C17, ASCII, 8-bit bytes, and 32-bit int/unsigned int unless an item specifies a different bit-width model.",
    "Bit and nibble indices start at zero at the least significant end. 1u means an unsigned int constant with value 1.",
    "Assume standard declarations are available, all stated objects are valid, and no concurrent changes occur.",
    "Originals with missing context or typos carry visible clarifications. Fixed-width wrapping exercises are explicitly distinguished from C integer promotions.",
    "For exam-style practice, follow the sample’s no-calculator, no-notes instruction. Answers are shown after submission."
  ],
  "groups": [
    {
      "id": "M01",
      "sourceQuestion": 1,
      "title": "Data, context, and interpretation",
      "competency": "Distinguish stored bits from the information needed to interpret their meaning.",
      "responseType": "mcq",
      "review": [
        "Identify the data and the missing interpretation rule separately.",
        "Review instruction sets, file formats, type information, and signedness.",
        "Explain why the same bits can represent different values or instructions."
      ]
    },
    {
      "id": "M02",
      "sourceQuestion": 2,
      "title": "Memory hierarchy",
      "competency": "Rank storage levels by typical access latency and distinguish latency from capacity.",
      "responseType": "mcq",
      "review": [
        "Recall registers → cache → RAM → secondary storage.",
        "Order L1, L2, and L3 within a conventional cache hierarchy.",
        "Distinguish fastest-to-slowest from slowest-to-fastest; access time from capacity."
      ]
    },
    {
      "id": "M03",
      "sourceQuestion": 3,
      "title": "Pointers and formatted output",
      "competency": "Trace aliases and dereferences, then match printf conversions to argument types.",
      "responseType": "mcq",
      "review": [
        "Track an address separately from the value at that address.",
        "Match %d to int and %p to a void pointer.",
        "Distinguish a compile-time constraint violation from undefined runtime behavior."
      ]
    },
    {
      "id": "M04",
      "sourceQuestion": 4,
      "title": "Valid array and pointer statements",
      "competency": "Decide which assignments and pointer operations satisfy C type and object rules.",
      "responseType": "mcq",
      "review": [
        "Arrays cannot be assigned as whole objects.",
        "Array expressions usually convert to pointers to their first elements.",
        "Review const, pointer-to-array types, and one-past pointers."
      ]
    },
    {
      "id": "M05",
      "sourceQuestion": 5,
      "title": "Hexadecimal to binary",
      "competency": "Translate every hexadecimal digit into four bits without changing byte order.",
      "responseType": "mcq",
      "review": [
        "Memorize the four-bit patterns for hexadecimal digits 0–F.",
        "Keep leading zeros for a specified width.",
        "Distinguish a number’s written binary representation from byte order in memory."
      ]
    },
    {
      "id": "M06",
      "sourceQuestion": 6,
      "title": "String input and buffer capacity",
      "competency": "Account for the null terminator and scanf field width when finding safe input lengths.",
      "responseType": "mcq",
      "review": [
        "A C string needs one byte beyond its visible characters.",
        "A %s field width excludes the terminating null byte.",
        "Width-limited input can leave the rest of an overlong token unread."
      ]
    },
    {
      "id": "M07",
      "sourceQuestion": 7,
      "title": "Nibble extraction",
      "competency": "Trace a shift-and-mask helper and identify the selected hexadecimal digit.",
      "responseType": "mcq",
      "review": [
        "Number nibbles from zero at the least significant end.",
        "Each hexadecimal digit spans four bits; isolate it with 0xF.",
        "Use unsigned operands or explicitly state signed conversion/shift assumptions."
      ]
    },
    {
      "id": "M08",
      "sourceQuestion": 8,
      "title": "Sign, parity, and byte order",
      "competency": "Infer sign and parity from a fixed-width two’s-complement bit pattern.",
      "responseType": "mcq",
      "review": [
        "The highest value bit determines the sign in two’s complement.",
        "The lowest value bit determines odd/even parity.",
        "Little endian changes byte placement, not the value’s sign or parity."
      ]
    },
    {
      "id": "M09",
      "sourceQuestion": 9,
      "title": "Alternative bit-string interpretations",
      "competency": "Compare unsigned, sign-magnitude, and two’s-complement interpretations of the same bits.",
      "responseType": "mcq",
      "review": [
        "Unsigned uses every bit as a positive weight.",
        "Sign-magnitude separates the sign bit and magnitude.",
        "For negative two’s complement, subtract 2^width from the unsigned value."
      ]
    },
    {
      "id": "M10",
      "sourceQuestion": 10,
      "title": "Sign extension",
      "competency": "Widen a two’s-complement bit pattern while preserving its signed value.",
      "responseType": "mcq",
      "review": [
        "Repeat the original sign bit in the added high positions.",
        "Positive values extend with zeros; negative values extend with ones.",
        "Check the decimal value before and after widening."
      ]
    },
    {
      "id": "M11",
      "sourceQuestion": 11,
      "title": "Bits discarded by shifts",
      "competency": "Determine when shifting right and then left loses information.",
      "responseType": "mcq",
      "review": [
        "Inspect the low k bits discarded by a right shift of k.",
        "For nonnegative values, unchanged means divisible by 2^k.",
        "Distinguish a fixed-width bit exercise from promoted signed C expressions."
      ]
    },
    {
      "id": "M12",
      "sourceQuestion": 12,
      "title": "Cross-nibble field extraction",
      "competency": "Extract a masked field that may span hexadecimal digit boundaries.",
      "responseType": "mcq",
      "review": [
        "Identify the rightmost source bit of the field.",
        "Shift that bit to position zero, then apply the width mask.",
        "Work nibble by nibble, especially for shifts not aligned to a whole byte."
      ]
    },
    {
      "id": "M13",
      "sourceQuestion": 13,
      "title": "Two’s-complement decoding",
      "competency": "Convert a fixed-width negative hexadecimal pattern to signed decimal.",
      "responseType": "mcq",
      "review": [
        "Determine the intended width before deciding the sign.",
        "Compute unsigned value minus 2^width when the top bit is set.",
        "Check minimum, maximum, minus one, and leading-zero cases."
      ]
    },
    {
      "id": "M14",
      "sourceQuestion": 14,
      "title": "Negation and integer promotion",
      "competency": "Separate fixed-width wrapping negation from actual C evaluation after promotions.",
      "responseType": "mcq",
      "review": [
        "Zero equals its own negation.",
        "The minimum signed pattern is also self-negating in a wrapping fixed-width model.",
        "An 8-bit signed char promotes to int before unary minus on the stated C machine."
      ]
    },
    {
      "id": "M15",
      "sourceQuestion": 15,
      "title": "Signed and unsigned comparison",
      "competency": "Apply promotions and the usual arithmetic conversions before comparing values.",
      "responseType": "mcq",
      "review": [
        "The U suffix changes the type of an integer constant.",
        "A negative int converted to unsigned int becomes a large nonnegative value.",
        "An unsigned char can promote to int; an unsigned int remains unsigned."
      ]
    },
    {
      "id": "M16",
      "sourceQuestion": 16,
      "title": "Narrowing and widening conversions",
      "competency": "Trace low-byte conversion and subsequent sign or zero extension under stated assumptions.",
      "responseType": "mcq",
      "review": [
        "Unsigned narrowing is reduction modulo 2^width.",
        "Signed out-of-range conversion is implementation-defined in C17.",
        "Plain char signedness must be specified before predicting a negative result."
      ]
    },
    {
      "id": "M17",
      "sourceQuestion": 17,
      "title": "Packed bit-array indexing",
      "competency": "Split a global bit index into byte index, local bit position, and a one-bit mask.",
      "responseType": "mcq",
      "review": [
        "For eight-bit bytes, byte index is i / 8 and local index is i % 8.",
        "For nonnegative i, i >> 3 and i & 7 implement those operations.",
        "Distinguish a set mask from a complemented clear mask and from the byte index."
      ]
    },
    {
      "id": "M18",
      "sourceQuestion": 18,
      "title": "Recognizing linked-list behavior",
      "competency": "Infer a traversal’s contract from its initialization, comparison, update, and return.",
      "responseType": "mcq",
      "review": [
        "Trace what happens for an empty list, head, middle node, and tail.",
        "Compare node identity separately from equality of stored values.",
        "Check whether the return value is a Boolean, count, index, or pointer."
      ]
    },
    {
      "id": "M19",
      "sourceQuestion": 19,
      "title": "Tracing memory and pointer updates",
      "competency": "Record array contents and pointer destinations after each statement.",
      "responseType": "trace",
      "review": [
        "Pointer addition moves by elements, whose addresses differ by sizeof(element).",
        "Dereferencing changes the object at the address; pointer reassignment changes the address.",
        "Distinguish *p++, (*p)++, p[i], and a one-past pointer."
      ]
    },
    {
      "id": "M20",
      "sourceQuestion": 20,
      "title": "Writing string traversal functions",
      "competency": "Implement a terminating scan and compute the requested string length or closely related count.",
      "responseType": "code",
      "review": [
        "Stop at the first null character and do not count it.",
        "Initialize counters and advance exactly once per examined character.",
        "Test empty strings, offsets, bounds, and embedded nulls as the contract requires."
      ]
    },
    {
      "id": "M21",
      "sourceQuestion": 21,
      "title": "Writing byte-oriented memory functions",
      "competency": "Implement exact byte writes with correct bounds and pointer return semantics.",
      "responseType": "code",
      "review": [
        "Convert void * to a character pointer before byte-wise access.",
        "Write precisely the requested range, preserving bytes outside it.",
        "Test zero size, interior ranges, byte conversion, and the required return pointer."
      ]
    }
  ],
  "questions": [
    {
      "id": "M01-O",
      "group": "M01",
      "sourceQuestion": 1,
      "sourcePage": 1,
      "variant": 0,
      "origin": "original",
      "type": "mcq",
      "question": "Given an object file compiled on some other system and you are asked: What does the code do? What statement best describes the situation?",
      "options": [
        "This is not possible as there is no data.",
        "This is not possible as there is no data and no context.",
        "This is possible because there is data and context.",
        "This is not possible as there is no context."
      ],
      "correct": 3,
      "explanation": "Under the stated missing-context assumption, D is the intended answer: the file provides data, but its interpretation is unknown. As written, the PDF is under-specified: many real object formats identify their architecture and can be analyzed. This is a conditional, independently derived key.",
      "note": "For this original, assume the target instruction set and object format are unknown and cannot be identified from metadata. “Compiled elsewhere” alone would not establish that interpretation is impossible."
    },
    {
      "id": "M01-V01",
      "group": "M01",
      "sourceQuestion": 1,
      "sourcePage": 1,
      "variant": 1,
      "origin": "variant",
      "type": "mcq",
      "question": "You receive raw machine-code bytes with no file header and no known target instruction set. What best describes your ability to decode the instructions?",
      "options": [
        "Neither stored data nor decoding context is present.",
        "Data is present; the decoding context is missing.",
        "Context is present; the stored data is missing.",
        "Both data and decoding context are present."
      ],
      "correct": 1,
      "explanation": "The bytes are the data. Instruction-set knowledge supplies the rules that map those bytes to instructions."
    },
    {
      "id": "M01-V02",
      "group": "M01",
      "sourceQuestion": 1,
      "sourcePage": 1,
      "variant": 2,
      "origin": "variant",
      "type": "mcq",
      "question": "The same 8-bit pattern is read as either an unsigned integer or an ASCII character. What determines which interpretation is appropriate?",
      "options": [
        "The number of ones in the stored byte.",
        "The physical address of the byte alone.",
        "The type or encoding expected by the surrounding program.",
        "The time at which the byte was written."
      ],
      "correct": 2,
      "explanation": "The bit pattern has no unique meaning by itself. The consumer’s type or encoding supplies the interpretation."
    },
    {
      "id": "M01-V03",
      "group": "M01",
      "sourceQuestion": 1,
      "sourcePage": 1,
      "variant": 3,
      "origin": "variant",
      "type": "mcq",
      "question": "An object file declares its target architecture and format in a recognized header, and a matching disassembler is available. Which conclusion is justified?",
      "options": [
        "Its instructions can be decoded using that context.",
        "Its instructions cannot be decoded because it was compiled elsewhere.",
        "Its exact original C source must be uniquely recoverable.",
        "Its exact original variable names must all be recoverable."
      ],
      "correct": 0,
      "explanation": "Recognized metadata and a matching decoder supply context. Decoding instructions does not guarantee recovery of exact source or names."
    },
    {
      "id": "M01-V04",
      "group": "M01",
      "sourceQuestion": 1,
      "sourcePage": 1,
      "variant": 4,
      "origin": "variant",
      "type": "mcq",
      "question": "You know a file contains 16-bit integers but do not know the byte order. What information is still missing?",
      "options": [
        "How successive bytes contribute to each integer’s value.",
        "Whether the file contains any stored data.",
        "How many bits are stored in each integer.",
        "How many distinct 16-bit patterns are possible."
      ],
      "correct": 0,
      "explanation": "Width is known, but byte order is needed to assign high and low significance to each byte."
    },
    {
      "id": "M01-V05",
      "group": "M01",
      "sourceQuestion": 1,
      "sourcePage": 1,
      "variant": 5,
      "origin": "variant",
      "type": "mcq",
      "question": "A debugger displays the same bytes once as a floating-point value and once as an integer. Which statement explains the differing values?",
      "options": [
        "Different interpretation rules are applied to the same data.",
        "The integer view always exposes the one true meaning.",
        "The bytes must have changed between the two views.",
        "The floating-point view always exposes the one true meaning."
      ],
      "correct": 0,
      "explanation": "A debugger can reinterpret unchanged storage through different type rules. Neither view is inherently the correct application meaning."
    },
    {
      "id": "M01-V06",
      "group": "M01",
      "sourceQuestion": 1,
      "sourcePage": 1,
      "variant": 6,
      "origin": "variant",
      "type": "mcq",
      "question": "A protocol says one byte is an unsigned count. The byte is 0xFF. Which statement best describes this situation?",
      "options": [
        "The data is available but every interpretation rule is missing.",
        "The interpretation rule is available but the data is missing.",
        "Neither the data nor an interpretation rule is available.",
        "Both the data and its interpretation rule are available."
      ],
      "correct": 3,
      "explanation": "The protocol supplies unsigned-count context and the byte supplies the data, so the value is 255."
    },
    {
      "id": "M01-V07",
      "group": "M01",
      "sourceQuestion": 1,
      "sourcePage": 1,
      "variant": 7,
      "origin": "variant",
      "type": "mcq",
      "question": "A bit sequence is given with no width, signedness, or encoding. What can be stated with certainty?",
      "options": [
        "The supplied bit sequence itself is known.",
        "Its machine instruction is uniquely known.",
        "Its text character is uniquely known.",
        "Its signed decimal value is uniquely known."
      ],
      "correct": 0,
      "explanation": "The literal bits are observable. Their intended numeric, text, or instruction meaning requires additional context."
    },
    {
      "id": "M01-V08",
      "group": "M01",
      "sourceQuestion": 1,
      "sourcePage": 1,
      "variant": 8,
      "origin": "variant",
      "type": "mcq",
      "question": "A program stores 0x41 in memory. One component expects ASCII text and another expects an unsigned byte. Which statement is valid?",
      "options": [
        "The components may read A and 65 from the same bits.",
        "The unsigned interpretation changes the stored bits to A.",
        "The components must read the same displayed text.",
        "The ASCII interpretation changes the stored bits to 65."
      ],
      "correct": 0,
      "explanation": "In ASCII, the code for A is 65, which is 0x41. Different displays need not imply a storage change."
    },
    {
      "id": "M01-V09",
      "group": "M01",
      "sourceQuestion": 1,
      "sourcePage": 1,
      "variant": 9,
      "origin": "variant",
      "type": "mcq",
      "question": "A file format is documented but the file’s payload bytes are unavailable. What best describes the missing information?",
      "options": [
        "Interpretation context is known, but the data to interpret is missing.",
        "The data is known, but all interpretation context is missing.",
        "Both the payload data and its context are known.",
        "The format description uniquely determines every payload byte."
      ],
      "correct": 0,
      "explanation": "A format describes how to interpret content; it does not supply the actual content of a particular file."
    },
    {
      "id": "M01-V10",
      "group": "M01",
      "sourceQuestion": 1,
      "sourcePage": 1,
      "variant": 10,
      "origin": "variant",
      "type": "mcq",
      "question": "Two instruction sets assign different instructions to the same byte pattern. What information selects the correct instruction decoder?",
      "options": [
        "The target instruction set used to encode the bytes.",
        "The compiler optimization level alone, regardless of the target.",
        "The byte order alone, regardless of the instruction set.",
        "The original source language, regardless of the target."
      ],
      "correct": 0,
      "explanation": "The target instruction set selects the decoding rule. Source language, byte order, or optimization level alone cannot identify that rule."
    },
    {
      "id": "M02-O",
      "group": "M02",
      "sourceQuestion": 2,
      "sourcePage": 1,
      "variant": 0,
      "origin": "original",
      "type": "mcq",
      "question": "Memory speeds, ranked fastest to slowest in terms of access times:",
      "options": [
        "II, III, IV, I",
        "III, II, IV, I",
        "II, IV, I, III",
        "IV, III, I, II"
      ],
      "correct": 3,
      "explanation": "In the conventional hierarchy, registers have the lowest access latency, then cache, main memory, and a mechanical hard disk.",
      "note": "Use the conventional qualitative hierarchy, not overlapping real-device benchmark ranges.",
      "statements": [
        "I  Main Memory",
        "II  Hard Disk",
        "III  Cache",
        "IV  Registers"
      ]
    },
    {
      "id": "M02-V01",
      "group": "M02",
      "sourceQuestion": 2,
      "sourcePage": 1,
      "variant": 1,
      "origin": "variant",
      "type": "mcq",
      "question": "Rank the following storage levels from fastest to slowest in typical access time.",
      "options": [
        "I, III, IV, II",
        "IV, II, III, I",
        "II, III, IV, I",
        "II, IV, III, I"
      ],
      "correct": 3,
      "explanation": "Use the conventional latency hierarchy: Registers → Cache → Main memory → Hard disk. This asks about access time, not storage capacity.",
      "note": "Assume a conventional system, with hits at the listed cache level.",
      "statements": [
        "I  Hard disk",
        "II  Registers",
        "III  Main memory",
        "IV  Cache"
      ],
      "verification": {
        "kind": "hierarchy",
        "levels": [
          "Hard disk",
          "Registers",
          "Main memory",
          "Cache"
        ],
        "reverse": false
      }
    },
    {
      "id": "M02-V02",
      "group": "M02",
      "sourceQuestion": 2,
      "sourcePage": 1,
      "variant": 2,
      "origin": "variant",
      "type": "mcq",
      "question": "Rank the following storage levels from fastest to slowest in typical access time.",
      "options": [
        "IV, III, I, II",
        "IV, I, III, II",
        "II, I, III, IV",
        "III, IV, I, II"
      ],
      "correct": 0,
      "explanation": "Use the conventional latency hierarchy: Registers → L1 cache → L2 cache → Main memory. This asks about access time, not storage capacity.",
      "note": "Assume a conventional system, with hits at the listed cache level.",
      "statements": [
        "I  L2 cache",
        "II  Main memory",
        "III  L1 cache",
        "IV  Registers"
      ],
      "verification": {
        "kind": "hierarchy",
        "levels": [
          "L2 cache",
          "Main memory",
          "L1 cache",
          "Registers"
        ],
        "reverse": false
      }
    },
    {
      "id": "M02-V03",
      "group": "M02",
      "sourceQuestion": 2,
      "sourcePage": 1,
      "variant": 3,
      "origin": "variant",
      "type": "mcq",
      "question": "Rank the following storage levels from fastest to slowest in typical access time.",
      "options": [
        "IV, III, II, I",
        "III, II, IV, I",
        "I, II, IV, III",
        "III, IV, II, I"
      ],
      "correct": 3,
      "explanation": "Use the conventional latency hierarchy: L1 cache → L2 cache → L3 cache → Main memory. This asks about access time, not storage capacity.",
      "note": "Assume a conventional system, with hits at the listed cache level.",
      "statements": [
        "I  Main memory",
        "II  L3 cache",
        "III  L1 cache",
        "IV  L2 cache"
      ],
      "verification": {
        "kind": "hierarchy",
        "levels": [
          "Main memory",
          "L3 cache",
          "L1 cache",
          "L2 cache"
        ],
        "reverse": false
      }
    },
    {
      "id": "M02-V04",
      "group": "M02",
      "sourceQuestion": 2,
      "sourcePage": 1,
      "variant": 4,
      "origin": "variant",
      "type": "mcq",
      "question": "Rank the following storage levels from slowest to fastest in typical access time.",
      "options": [
        "IV, III, I, II",
        "III, IV, I, II",
        "III, I, IV, II",
        "II, I, IV, III"
      ],
      "correct": 1,
      "explanation": "Use the conventional latency hierarchy: Hard disk → Main memory → Cache → Registers. This asks about access time, not storage capacity.",
      "note": "Assume a conventional system, with hits at the listed cache level.",
      "statements": [
        "I  Cache",
        "II  Registers",
        "III  Hard disk",
        "IV  Main memory"
      ],
      "verification": {
        "kind": "hierarchy",
        "levels": [
          "Cache",
          "Registers",
          "Hard disk",
          "Main memory"
        ],
        "reverse": true
      }
    },
    {
      "id": "M02-V05",
      "group": "M02",
      "sourceQuestion": 2,
      "sourcePage": 1,
      "variant": 5,
      "origin": "variant",
      "type": "mcq",
      "question": "Rank the following storage levels from fastest to slowest in typical access time.",
      "options": [
        "IV, III, II, I",
        "III, IV, II, I",
        "III, II, IV, I",
        "I, II, IV, III"
      ],
      "correct": 1,
      "explanation": "Use the conventional latency hierarchy: Registers → L1 cache → Main memory → SSD storage. This asks about access time, not storage capacity.",
      "note": "Assume a conventional system, with hits at the listed cache level.",
      "statements": [
        "I  SSD storage",
        "II  Main memory",
        "III  Registers",
        "IV  L1 cache"
      ],
      "verification": {
        "kind": "hierarchy",
        "levels": [
          "SSD storage",
          "Main memory",
          "Registers",
          "L1 cache"
        ],
        "reverse": false
      }
    },
    {
      "id": "M02-V06",
      "group": "M02",
      "sourceQuestion": 2,
      "sourcePage": 1,
      "variant": 6,
      "origin": "variant",
      "type": "mcq",
      "question": "Rank the following storage levels from slowest to fastest in typical access time.",
      "options": [
        "I, III, II, IV",
        "IV, II, III, I",
        "I, II, III, IV",
        "III, I, II, IV"
      ],
      "correct": 0,
      "explanation": "Use the conventional latency hierarchy: L3 cache → L2 cache → L1 cache → Registers. This asks about access time, not storage capacity.",
      "note": "Assume a conventional system, with hits at the listed cache level.",
      "statements": [
        "I  L3 cache",
        "II  L1 cache",
        "III  L2 cache",
        "IV  Registers"
      ],
      "verification": {
        "kind": "hierarchy",
        "levels": [
          "L3 cache",
          "L1 cache",
          "L2 cache",
          "Registers"
        ],
        "reverse": true
      }
    },
    {
      "id": "M02-V07",
      "group": "M02",
      "sourceQuestion": 2,
      "sourcePage": 1,
      "variant": 7,
      "origin": "variant",
      "type": "mcq",
      "question": "Rank the following storage levels from fastest to slowest in typical access time.",
      "options": [
        "I, II, III, IV",
        "IV, III, II, I",
        "IV, II, III, I",
        "III, IV, II, I"
      ],
      "correct": 1,
      "explanation": "Use the conventional latency hierarchy: Cache → Main memory → SSD storage → Hard disk. This asks about access time, not storage capacity.",
      "note": "Assume a conventional system, with hits at the listed cache level.",
      "statements": [
        "I  Hard disk",
        "II  SSD storage",
        "III  Main memory",
        "IV  Cache"
      ],
      "verification": {
        "kind": "hierarchy",
        "levels": [
          "Hard disk",
          "SSD storage",
          "Main memory",
          "Cache"
        ],
        "reverse": false
      }
    },
    {
      "id": "M02-V08",
      "group": "M02",
      "sourceQuestion": 2,
      "sourcePage": 1,
      "variant": 8,
      "origin": "variant",
      "type": "mcq",
      "question": "Rank the following storage levels from slowest to fastest in typical access time.",
      "options": [
        "I, II, III, IV",
        "III, IV, II, I",
        "IV, II, III, I",
        "IV, III, II, I"
      ],
      "correct": 3,
      "explanation": "Use the conventional latency hierarchy: Hard disk → Main memory → Cache → Registers. This asks about access time, not storage capacity.",
      "note": "Assume a conventional system, with hits at the listed cache level.",
      "statements": [
        "I  Registers",
        "II  Cache",
        "III  Main memory",
        "IV  Hard disk"
      ],
      "verification": {
        "kind": "hierarchy",
        "levels": [
          "Registers",
          "Cache",
          "Main memory",
          "Hard disk"
        ],
        "reverse": true
      }
    },
    {
      "id": "M02-V09",
      "group": "M02",
      "sourceQuestion": 2,
      "sourcePage": 1,
      "variant": 9,
      "origin": "variant",
      "type": "mcq",
      "question": "Rank the following storage levels from slowest to fastest in typical access time.",
      "options": [
        "II, I, III, IV",
        "IV, I, III, II",
        "II, III, I, IV",
        "III, II, I, IV"
      ],
      "correct": 2,
      "explanation": "Use the conventional latency hierarchy: SSD storage → Main memory → L1 cache → Registers. This asks about access time, not storage capacity.",
      "note": "Assume a conventional system, with hits at the listed cache level.",
      "statements": [
        "I  L1 cache",
        "II  SSD storage",
        "III  Main memory",
        "IV  Registers"
      ],
      "verification": {
        "kind": "hierarchy",
        "levels": [
          "L1 cache",
          "SSD storage",
          "Main memory",
          "Registers"
        ],
        "reverse": true
      }
    },
    {
      "id": "M02-V10",
      "group": "M02",
      "sourceQuestion": 2,
      "sourcePage": 1,
      "variant": 10,
      "origin": "variant",
      "type": "mcq",
      "question": "Rank the following storage levels from slowest to fastest in typical access time.",
      "options": [
        "III, IV, II, I",
        "I, IV, II, III",
        "II, I, IV, III",
        "I, II, IV, III"
      ],
      "correct": 3,
      "explanation": "Use the conventional latency hierarchy: Main memory → L2 cache → L1 cache → Registers. This asks about access time, not storage capacity.",
      "note": "Assume a conventional system, with hits at the listed cache level.",
      "statements": [
        "I  Main memory",
        "II  L2 cache",
        "III  Registers",
        "IV  L1 cache"
      ],
      "verification": {
        "kind": "hierarchy",
        "levels": [
          "Main memory",
          "L2 cache",
          "Registers",
          "L1 cache"
        ],
        "reverse": true
      }
    },
    {
      "id": "M03-O",
      "group": "M03",
      "sourceQuestion": 3,
      "sourcePage": 1,
      "variant": 0,
      "origin": "original",
      "type": "mcq",
      "question": "What would be printed by the code snippet below?",
      "options": [
        "Nothing, the code will not compile.",
        "42",
        "32",
        "The answer is unpredictable"
      ],
      "correct": 3,
      "explanation": "%d requires an int argument, but ptr is an int pointer. The mismatched variadic argument causes undefined behavior; compilation may still succeed with a warning. Dereferencing ptr would instead supply the int value 32.",
      "code": "int val = 42;\nint *ptr = &val;\nval = 32;\nprintf(\"%d\\n\", ptr);"
    },
    {
      "id": "M03-V01",
      "group": "M03",
      "sourceQuestion": 3,
      "sourcePage": 1,
      "variant": 1,
      "origin": "variant",
      "type": "mcq",
      "question": "What would be printed by the code snippet below?",
      "options": [
        "The pointer address",
        "27",
        "19",
        "Undefined behavior"
      ],
      "correct": 1,
      "explanation": "ptr still points to val, whose current value is 27. *ptr reads that current int.",
      "code": "int val = 19;\nint *ptr = &val;\nval = 27;\nprintf(\"%d\", *ptr);",
      "verification": {
        "kind": "output",
        "expected": "27"
      }
    },
    {
      "id": "M03-V02",
      "group": "M03",
      "sourceQuestion": 3,
      "sourcePage": 1,
      "variant": 2,
      "origin": "variant",
      "type": "mcq",
      "question": "What would be printed by the code snippet below?",
      "options": [
        "7 12",
        "9 9",
        "9 12",
        "12 9"
      ],
      "correct": 3,
      "explanation": "q retains the address of a after p is redirected to b. Writing through q changes a to 9.",
      "code": "int a = 7, b = 12;\nint *p = &a;\nint *q = p;\np = &b;\n*q = 9;\nprintf(\"%d %d\", *p, a);",
      "verification": {
        "kind": "output",
        "expected": "12 9"
      }
    },
    {
      "id": "M03-V03",
      "group": "M03",
      "sourceQuestion": 3,
      "sourcePage": 1,
      "variant": 3,
      "origin": "variant",
      "type": "mcq",
      "question": "What would be printed by the code snippet below?",
      "options": [
        "24",
        "Undefined behavior",
        "8",
        "16"
      ],
      "correct": 0,
      "explanation": "p points to a[1], so p + 1 points to a[2]. Dereferencing that valid element gives 24.",
      "code": "int a[] = {8, 16, 24};\nint *p = a + 1;\nprintf(\"%d\", *(p + 1));",
      "verification": {
        "kind": "output",
        "expected": "24"
      }
    },
    {
      "id": "M03-V04",
      "group": "M03",
      "sourceQuestion": 3,
      "sourcePage": 1,
      "variant": 4,
      "origin": "variant",
      "type": "mcq",
      "question": "What would be printed by the code snippet below?",
      "options": [
        "The address of x",
        "Undefined behavior",
        "A required compilation error",
        "6"
      ],
      "correct": 1,
      "explanation": "%d expects int, but &x has type int *. A format mismatch is undefined behavior even if the compiler only warns.",
      "code": "int x = 6;\nprintf(\"%d\", &x);"
    },
    {
      "id": "M03-V05",
      "group": "M03",
      "sourceQuestion": 3,
      "sourcePage": 1,
      "variant": 5,
      "origin": "variant",
      "type": "mcq",
      "question": "What would be printed by the code snippet below?",
      "options": [
        "7 3",
        "3 7",
        "7 7",
        "3 3"
      ],
      "correct": 2,
      "explanation": "x and *p designate the same object. The assignment changes that object to 7.",
      "code": "int x = 3;\nint *p = &x;\n*p += 4;\nprintf(\"%d %d\", x, *p);",
      "verification": {
        "kind": "output",
        "expected": "7 7"
      }
    },
    {
      "id": "M03-V06",
      "group": "M03",
      "sourceQuestion": 3,
      "sourcePage": 1,
      "variant": 6,
      "origin": "variant",
      "type": "mcq",
      "question": "What would be printed by the code snippet below?",
      "options": [
        "4 6",
        "2 2",
        "3 2",
        "2 4"
      ],
      "correct": 3,
      "explanation": "Postfix ++ binds to p. The old pointer is dereferenced to obtain 2, and p then points to a[1].",
      "code": "int a[] = {2, 4, 6};\nint *p = a;\nint old = *p++;\nprintf(\"%d %d\", old, *p);",
      "verification": {
        "kind": "output",
        "expected": "2 4"
      }
    },
    {
      "id": "M03-V07",
      "group": "M03",
      "sourceQuestion": 3,
      "sourcePage": 1,
      "variant": 7,
      "origin": "variant",
      "type": "mcq",
      "question": "What would be printed by the code snippet below?",
      "options": [
        "3 3",
        "3 4",
        "2 4",
        "2 2"
      ],
      "correct": 0,
      "explanation": "Parentheses apply ++ to the pointed-to int. The first element becomes 3 and p does not move.",
      "code": "int a[] = {2, 4, 6};\nint *p = a;\n(*p)++;\nprintf(\"%d %d\", a[0], *p);",
      "verification": {
        "kind": "output",
        "expected": "3 3"
      }
    },
    {
      "id": "M03-V08",
      "group": "M03",
      "sourceQuestion": 3,
      "sourcePage": 1,
      "variant": 8,
      "origin": "variant",
      "type": "mcq",
      "question": "What would be printed by the code snippet below?",
      "options": [
        "18",
        "Undefined behavior",
        "14",
        "The address of p"
      ],
      "correct": 0,
      "explanation": "*q is p and **q is x. Assigning through both levels modifies x.",
      "code": "int x = 14;\nint *p = &x;\nint **q = &p;\n**q = 18;\nprintf(\"%d\", x);",
      "verification": {
        "kind": "output",
        "expected": "18"
      }
    },
    {
      "id": "M03-V09",
      "group": "M03",
      "sourceQuestion": 3,
      "sourcePage": 1,
      "variant": 9,
      "origin": "variant",
      "type": "mcq",
      "question": "What best describes the output of this code?",
      "options": [
        "A representation of the address stored in p",
        "Undefined behavior from the format",
        "The decimal value sizeof(int)",
        "The decimal value 21"
      ],
      "correct": 0,
      "explanation": "%p expects a void * argument; the explicit cast provides it. The implementation chooses the address representation, so a specific numeric address cannot be predicted.",
      "code": "int x = 21;\nint *p = &x;\nprintf(\"%p\", (void *)p);"
    },
    {
      "id": "M03-V10",
      "group": "M03",
      "sourceQuestion": 3,
      "sourcePage": 1,
      "variant": 10,
      "origin": "variant",
      "type": "mcq",
      "question": "What would be printed by the code snippet below?",
      "options": [
        "11 11",
        "11 30",
        "30 30",
        "30 11"
      ],
      "correct": 1,
      "explanation": "copy stores the earlier integer value. p retains the address and reads x’s new value.",
      "code": "int x = 11;\nint *p = &x;\nint copy = *p;\nx = 30;\nprintf(\"%d %d\", copy, *p);",
      "verification": {
        "kind": "output",
        "expected": "11 30"
      }
    },
    {
      "id": "M04-O",
      "group": "M04",
      "sourceQuestion": 4,
      "sourcePage": 1,
      "variant": 0,
      "origin": "original",
      "type": "mcq",
      "question": "Given the variable declarations below, which of the following statements would be valid?",
      "options": [
        "I & II",
        "I & IV",
        "II, III & IV",
        "I, II, III, & IV"
      ],
      "correct": 0,
      "explanation": "I and II are type-correct assignments to a pointer variable. III and IV attempt to assign to an array, which is not a modifiable lvalue. An automatic uninitialized ptr would make actually evaluating I unsafe; this question is about assignment validity.",
      "code": "int val[3];\nint *ptr;",
      "note": "Judge assignment/type compatibility. Treat ptr as initialized before any statement is evaluated; the PDF omits that runtime precondition.",
      "statements": [
        "I   ptr = ptr;",
        "II  ptr = val;",
        "III val = ptr;",
        "IV  val = val;"
      ]
    },
    {
      "id": "M04-V01",
      "group": "M04",
      "sourceQuestion": 4,
      "sourcePage": 1,
      "variant": 1,
      "origin": "variant",
      "type": "mcq",
      "question": "Each statement is considered independently, starting from these declarations. Which statements are valid C and, when evaluated, stay within the stated objects?",
      "options": [
        "II, III",
        "I, II, IV",
        "I, II",
        "I, III"
      ],
      "correct": 3,
      "explanation": "A pointer is assignable; a whole array is not. Both a + 2 and &a[0] have type int *.",
      "code": "int a[4] = {0};\nint *p = a;",
      "statements": [
        "I  p = a + 2;",
        "II  a = p;",
        "III  p = &a[0];",
        "IV  a = a;"
      ],
      "verification": {
        "kind": "validStatements",
        "valid": [
          0,
          2
        ]
      }
    },
    {
      "id": "M04-V02",
      "group": "M04",
      "sourceQuestion": 4,
      "sourcePage": 1,
      "variant": 2,
      "origin": "variant",
      "type": "mcq",
      "question": "Each statement is considered independently, starting from these declarations. Which statements are valid C and, when evaluated, stay within the stated objects?",
      "options": [
        "I, II",
        "I, III",
        "II, III",
        "I, II, IV"
      ],
      "correct": 3,
      "explanation": "p can move within the array, and elements are writable. a is an array object, not an incrementable pointer variable.",
      "code": "int a[4] = {0};\nint *p = a;",
      "statements": [
        "I  p++;",
        "II  (*p)++;",
        "III  a++;",
        "IV  a[0] = 7;"
      ],
      "verification": {
        "kind": "validStatements",
        "valid": [
          0,
          1,
          3
        ]
      }
    },
    {
      "id": "M04-V03",
      "group": "M04",
      "sourceQuestion": 4,
      "sourcePage": 1,
      "variant": 3,
      "origin": "variant",
      "type": "mcq",
      "question": "Each statement is considered independently, starting from these declarations. Which statements are valid C and, when evaluated, stay within the stated objects?",
      "options": [
        "I, III",
        "I, II",
        "I, III, IV",
        "II, III"
      ],
      "correct": 2,
      "explanation": "p may be reassigned, but it cannot be used to modify a const-qualified int. The original a remains writable.",
      "code": "int a[4] = {0};\nconst int *p = a;",
      "statements": [
        "I  p = a + 1;",
        "II  *p = 5;",
        "III  a[0] = 5;",
        "IV  p++;"
      ],
      "verification": {
        "kind": "validStatements",
        "valid": [
          0,
          2,
          3
        ]
      }
    },
    {
      "id": "M04-V04",
      "group": "M04",
      "sourceQuestion": 4,
      "sourcePage": 1,
      "variant": 4,
      "origin": "variant",
      "type": "mcq",
      "question": "Each statement is considered independently, starting from these declarations. Which statements are valid C and, when evaluated, stay within the stated objects?",
      "options": [
        "II, III",
        "I, II",
        "I, III",
        "II, IV"
      ],
      "correct": 3,
      "explanation": "The const pointer cannot change its address, but its pointed-to ints are writable.",
      "code": "int a[4] = {0};\nint * const p = a;",
      "statements": [
        "I  p = a + 1;",
        "II  *p = 5;",
        "III  p++;",
        "IV  p[2] = 9;"
      ],
      "verification": {
        "kind": "validStatements",
        "valid": [
          1,
          3
        ]
      }
    },
    {
      "id": "M04-V05",
      "group": "M04",
      "sourceQuestion": 4,
      "sourcePage": 1,
      "variant": 5,
      "origin": "variant",
      "type": "mcq",
      "question": "Each statement is considered independently, starting from these declarations. Which statements are valid C and, when evaluated, stay within the stated objects?",
      "options": [
        "I, II, IV",
        "II, III",
        "I, II",
        "I, III"
      ],
      "correct": 1,
      "explanation": "&a has pointer-to-array type, while *a is an int. Only II and III provide an int pointer.",
      "code": "int a[4] = {0};\nint *p = a;",
      "statements": [
        "I  p = &a;",
        "II  p = a;",
        "III  p = &a[2];",
        "IV  p = *a;"
      ],
      "verification": {
        "kind": "validStatements",
        "valid": [
          1,
          2
        ]
      }
    },
    {
      "id": "M04-V06",
      "group": "M04",
      "sourceQuestion": 4,
      "sourcePage": 1,
      "variant": 6,
      "origin": "variant",
      "type": "mcq",
      "question": "Each statement is considered independently, starting from these declarations. Which statements are valid C and, when evaluated, stay within the stated objects?",
      "options": [
        "I, II, IV",
        "I, II",
        "I, III",
        "II, III"
      ],
      "correct": 2,
      "explanation": "p points to a whole four-int array. Its target’s elements are writable, but the whole array cannot be assigned.",
      "code": "int a[4] = {0};\nint (*p)[4] = &a;",
      "statements": [
        "I  p = &a;",
        "II  p = a;",
        "III  (*p)[1] = 6;",
        "IV  *p = a;"
      ],
      "verification": {
        "kind": "validStatements",
        "valid": [
          0,
          2
        ]
      }
    },
    {
      "id": "M04-V07",
      "group": "M04",
      "sourceQuestion": 4,
      "sourcePage": 1,
      "variant": 7,
      "origin": "variant",
      "type": "mcq",
      "question": "Each statement is considered independently, starting from these declarations. Which statements are valid C and, when evaluated, stay within the stated objects?",
      "options": [
        "II, III",
        "I, II",
        "I, III",
        "I, II, IV"
      ],
      "correct": 3,
      "explanation": "s is a writable array, so its elements can change. The array itself cannot be reassigned to a string literal.",
      "code": "char s[] = \"abc\";\nchar *p = s;",
      "statements": [
        "I  s[0] = 'x';",
        "II  p = s + 1;",
        "III  s = \"xyz\";",
        "IV  p[1] = 'y';"
      ],
      "verification": {
        "kind": "validStatements",
        "valid": [
          0,
          1,
          3
        ]
      }
    },
    {
      "id": "M04-V08",
      "group": "M04",
      "sourceQuestion": 4,
      "sourcePage": 1,
      "variant": 8,
      "origin": "variant",
      "type": "mcq",
      "question": "Each statement is considered independently, starting from these declarations. Which statements are valid C and, when evaluated, stay within the stated objects?",
      "options": [
        "I, III",
        "II, III",
        "I, II, IV",
        "I, II"
      ],
      "correct": 0,
      "explanation": "A pointer may be formed within the array or one past it. Forming a + 4 or a - 1 goes outside that allowed range.",
      "code": "int a[3] = {1, 2, 3};\nint *p = a;",
      "statements": [
        "I  p = a + 3;",
        "II  p = a + 4;",
        "III  p = &a[2];",
        "IV  p = a - 1;"
      ],
      "verification": {
        "kind": "validStatements",
        "valid": [
          0,
          2
        ]
      }
    },
    {
      "id": "M04-V09",
      "group": "M04",
      "sourceQuestion": 4,
      "sourcePage": 1,
      "variant": 9,
      "origin": "variant",
      "type": "mcq",
      "question": "Each statement is considered independently, starting from these declarations. Which statements are valid C and, when evaluated, stay within the stated objects?",
      "options": [
        "I, II",
        "I, II, IV",
        "I, III",
        "II, III"
      ],
      "correct": 1,
      "explanation": "NULL and the integer constant zero are null pointer constants. The integer constant 1 is not one and requires a diagnostic in this pointer assignment.",
      "code": "int a[3] = {0};\nint *p = a;",
      "statements": [
        "I  p = NULL;",
        "II  p = 0;",
        "III  p = 1;",
        "IV  p = &a[1];"
      ],
      "verification": {
        "kind": "validStatements",
        "valid": [
          0,
          1,
          3
        ]
      }
    },
    {
      "id": "M04-V10",
      "group": "M04",
      "sourceQuestion": 4,
      "sourcePage": 1,
      "variant": 10,
      "origin": "variant",
      "type": "mcq",
      "question": "Each statement is considered independently, starting from these declarations. Which statements are valid C and, when evaluated, stay within the stated objects?",
      "options": [
        "I, II",
        "I, III",
        "II, III",
        "I, III, IV"
      ],
      "correct": 3,
      "explanation": "q requires int **, while p is only int *. Through q, the pointer p and then its pointed-to int can both be accessed.",
      "code": "int a[3] = {0};\nint *p = a;\nint **q = &p;",
      "statements": [
        "I  q = &p;",
        "II  q = p;",
        "III  *q = a + 1;",
        "IV  **q = 4;"
      ],
      "verification": {
        "kind": "validStatements",
        "valid": [
          0,
          2,
          3
        ]
      }
    },
    {
      "id": "M05-O",
      "group": "M05",
      "sourceQuestion": 5,
      "sourcePage": 2,
      "variant": 0,
      "origin": "original",
      "type": "mcq",
      "question": "What is the binary representation of the 32 bit hex value 0xcafedead?",
      "options": [
        "00001101 11010000 11111110 11001010",
        "10101100 11101111 00001101 11010000",
        "11001010 11111110 11011110 10101101",
        "1010000 00001101 11101111 10101100"
      ],
      "correct": 2,
      "explanation": "Each hexadecimal digit contributes four bits: C A F E D E A D becomes 1100 1010 1111 1110 1101 1110 1010 1101. The last original option also has an inconsistent group width.",
      "verification": {
        "kind": "binary",
        "value": 3405700781
      }
    },
    {
      "id": "M05-V01",
      "group": "M05",
      "sourceQuestion": 5,
      "sourcePage": 2,
      "variant": 1,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the binary representation of the 32-bit hexadecimal value 0xA17C03E9?",
      "options": [
        "00010111 11000000 00111110 10011010",
        "10100001 01111100 00000011 11111001",
        "11101001 00000011 01111100 10100001",
        "10100001 01111100 00000011 11101001"
      ],
      "correct": 3,
      "explanation": "Translate the digits in their written order: 1010 0001 0111 1100 0000 0011 1110 1001. Endianness does not reverse a number’s written representation.",
      "verification": {
        "kind": "binary",
        "value": 2709259241
      }
    },
    {
      "id": "M05-V02",
      "group": "M05",
      "sourceQuestion": 5,
      "sourcePage": 2,
      "variant": 2,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the binary representation of the 32-bit hexadecimal value 0x08F2B640?",
      "options": [
        "00001000 11110010 10110110 01010000",
        "00001000 11110010 10110110 01000000",
        "10001111 00101011 01100100 00000000",
        "01000000 10110110 11110010 00001000"
      ],
      "correct": 1,
      "explanation": "Translate the digits in their written order: 0000 1000 1111 0010 1011 0110 0100 0000. Endianness does not reverse a number’s written representation.",
      "verification": {
        "kind": "binary",
        "value": 150124096
      }
    },
    {
      "id": "M05-V03",
      "group": "M05",
      "sourceQuestion": 5,
      "sourcePage": 2,
      "variant": 3,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the binary representation of the 32-bit hexadecimal value 0xDEAD102F?",
      "options": [
        "11011110 10101101 00010000 00111111",
        "11011110 10101101 00010000 00101111",
        "00101111 00010000 10101101 11011110",
        "11101010 11010001 00000010 11111101"
      ],
      "correct": 1,
      "explanation": "Translate the digits in their written order: 1101 1110 1010 1101 0001 0000 0010 1111. Endianness does not reverse a number’s written representation.",
      "verification": {
        "kind": "binary",
        "value": 3735883823
      }
    },
    {
      "id": "M05-V04",
      "group": "M05",
      "sourceQuestion": 5,
      "sourcePage": 2,
      "variant": 4,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the binary representation of the 32-bit hexadecimal value 0x7F0081C3?",
      "options": [
        "11110000 00001000 00011100 00110111",
        "01111111 00000000 10000001 11010011",
        "11000011 10000001 00000000 01111111",
        "01111111 00000000 10000001 11000011"
      ],
      "correct": 3,
      "explanation": "Translate the digits in their written order: 0111 1111 0000 0000 1000 0001 1100 0011. Endianness does not reverse a number’s written representation.",
      "verification": {
        "kind": "binary",
        "value": 2130739651
      }
    },
    {
      "id": "M05-V05",
      "group": "M05",
      "sourceQuestion": 5,
      "sourcePage": 2,
      "variant": 5,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the binary representation of the 32-bit hexadecimal value 0x80000001?",
      "options": [
        "10000000 00000000 00000000 00010001",
        "00000001 00000000 00000000 10000000",
        "10000000 00000000 00000000 00000001",
        "00000000 00000000 00000000 00011000"
      ],
      "correct": 2,
      "explanation": "Translate the digits in their written order: 1000 0000 0000 0000 0000 0000 0000 0001. Endianness does not reverse a number’s written representation.",
      "verification": {
        "kind": "binary",
        "value": 2147483649
      }
    },
    {
      "id": "M05-V06",
      "group": "M05",
      "sourceQuestion": 5,
      "sourcePage": 2,
      "variant": 6,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the binary representation of the 32-bit hexadecimal value 0x13579BDF?",
      "options": [
        "11011111 10011011 01010111 00010011",
        "00010011 01010111 10011011 11001111",
        "00110101 01111001 10111101 11110001",
        "00010011 01010111 10011011 11011111"
      ],
      "correct": 3,
      "explanation": "Translate the digits in their written order: 0001 0011 0101 0111 1001 1011 1101 1111. Endianness does not reverse a number’s written representation.",
      "verification": {
        "kind": "binary",
        "value": 324508639
      }
    },
    {
      "id": "M05-V07",
      "group": "M05",
      "sourceQuestion": 5,
      "sourcePage": 2,
      "variant": 7,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the binary representation of the 32-bit hexadecimal value 0x2468ACE0?",
      "options": [
        "11100000 10101100 01101000 00100100",
        "00100100 01101000 10101100 11110000",
        "00100100 01101000 10101100 11100000",
        "01000110 10001010 11001110 00000010"
      ],
      "correct": 2,
      "explanation": "Translate the digits in their written order: 0010 0100 0110 1000 1010 1100 1110 0000. Endianness does not reverse a number’s written representation.",
      "verification": {
        "kind": "binary",
        "value": 610839776
      }
    },
    {
      "id": "M05-V08",
      "group": "M05",
      "sourceQuestion": 5,
      "sourcePage": 2,
      "variant": 8,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the binary representation of the 32-bit hexadecimal value 0x00FF10A5?",
      "options": [
        "00000000 11111111 00010000 10100101",
        "00001111 11110001 00001010 01010000",
        "00000000 11111111 00010000 10110101",
        "10100101 00010000 11111111 00000000"
      ],
      "correct": 0,
      "explanation": "Translate the digits in their written order: 0000 0000 1111 1111 0001 0000 1010 0101. Endianness does not reverse a number’s written representation.",
      "verification": {
        "kind": "binary",
        "value": 16715941
      }
    },
    {
      "id": "M05-V09",
      "group": "M05",
      "sourceQuestion": 5,
      "sourcePage": 2,
      "variant": 9,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the binary representation of the 32-bit hexadecimal value 0xF00DC0DE?",
      "options": [
        "00000000 11011100 00001101 11101111",
        "11110000 00001101 11000000 11011110",
        "11110000 00001101 11000000 11001110",
        "11011110 11000000 00001101 11110000"
      ],
      "correct": 1,
      "explanation": "Translate the digits in their written order: 1111 0000 0000 1101 1100 0000 1101 1110. Endianness does not reverse a number’s written representation.",
      "verification": {
        "kind": "binary",
        "value": 4027433182
      }
    },
    {
      "id": "M05-V10",
      "group": "M05",
      "sourceQuestion": 5,
      "sourcePage": 2,
      "variant": 10,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the binary representation of the 32-bit hexadecimal value 0x10203040?",
      "options": [
        "00010000 00100000 00110000 01000000",
        "00000010 00000011 00000100 00000001",
        "01000000 00110000 00100000 00010000",
        "00010000 00100000 00110000 01010000"
      ],
      "correct": 0,
      "explanation": "Translate the digits in their written order: 0001 0000 0010 0000 0011 0000 0100 0000. Endianness does not reverse a number’s written representation.",
      "verification": {
        "kind": "binary",
        "value": 270544960
      }
    },
    {
      "id": "M06-O",
      "group": "M06",
      "sourceQuestion": 6,
      "sourcePage": 2,
      "variant": 0,
      "origin": "original",
      "type": "mcq",
      "question": "What is the max. length input allowed by this code to ensure correct operation?",
      "options": [
        "Unknown",
        "8",
        "9",
        "10"
      ],
      "correct": 2,
      "explanation": "The intended capacity answer is nine non-whitespace characters plus one null terminator. Unbounded %s does not enforce that limit. Literal transcription has a missing semicolon and typographic quotation marks, so those printing artifacts must be corrected before compiling.",
      "code": "char buffer[10];\nprintf(\"What is your name?\\n\")\nscanf(“%s”, buffer);\nprintf(“Hello %s\\n”, buffer);",
      "note": "For the intended buffer-capacity question, treat the missing semicolon and curly quotes in the PDF as typographical errors. Count one whitespace-delimited input token, excluding its terminator."
    },
    {
      "id": "M06-V01",
      "group": "M06",
      "sourceQuestion": 6,
      "sourcePage": 2,
      "variant": 1,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the maximum number of non-whitespace input characters this destination can safely store as a C string?",
      "options": [
        "7",
        "4",
        "6",
        "5"
      ],
      "correct": 3,
      "explanation": "The writable destination has 6 bytes, so 5 are available for input characters and one for the null terminator.",
      "code": "char buffer[6];\nscanf(\"%s\", buffer);",
      "verification": {
        "kind": "capacity",
        "capacity": 6,
        "width": null,
        "offset": 0
      }
    },
    {
      "id": "M06-V02",
      "group": "M06",
      "sourceQuestion": 6,
      "sourcePage": 2,
      "variant": 2,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the maximum number of non-whitespace input characters this destination can safely store as a C string?",
      "options": [
        "17",
        "15",
        "16",
        "18"
      ],
      "correct": 2,
      "explanation": "The writable destination has 17 bytes, so 16 are available for input characters and one for the null terminator.",
      "code": "char buffer[17];\nscanf(\"%s\", buffer);",
      "verification": {
        "kind": "capacity",
        "capacity": 17,
        "width": null,
        "offset": 0
      }
    },
    {
      "id": "M06-V03",
      "group": "M06",
      "sourceQuestion": 6,
      "sourcePage": 2,
      "variant": 3,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the maximum number of non-whitespace input characters this destination can safely store as a C string?",
      "options": [
        "1",
        "Unknown",
        "0",
        "2"
      ],
      "correct": 2,
      "explanation": "The writable destination has 1 bytes, so 0 are available for input characters and one for the null terminator.",
      "code": "char buffer[1];\nscanf(\"%s\", buffer);",
      "verification": {
        "kind": "capacity",
        "capacity": 1,
        "width": null,
        "offset": 0
      }
    },
    {
      "id": "M06-V04",
      "group": "M06",
      "sourceQuestion": 6,
      "sourcePage": 2,
      "variant": 4,
      "origin": "variant",
      "type": "mcq",
      "question": "For an input token longer than the field width, how many input characters can this call store, excluding the null terminator?",
      "options": [
        "12",
        "8",
        "10",
        "7"
      ],
      "correct": 3,
      "explanation": "The field width limits this conversion to 7 input characters, followed by a null terminator. The destination has enough room; remaining token characters stay unread.",
      "code": "char buffer[12];\nscanf(\"%7s\", buffer);",
      "verification": {
        "kind": "capacity",
        "capacity": 12,
        "width": 7,
        "offset": 0
      }
    },
    {
      "id": "M06-V05",
      "group": "M06",
      "sourceQuestion": 6,
      "sourcePage": 2,
      "variant": 5,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the maximum number of non-whitespace input characters this destination can safely store as a C string?",
      "options": [
        "9",
        "8",
        "7",
        "6"
      ],
      "correct": 2,
      "explanation": "The writable destination has 8 bytes, so 7 are available for input characters and one for the null terminator. The width 8 shown is too large and does not guarantee safety for a longer token.",
      "code": "char buffer[8];\nscanf(\"%8s\", buffer);",
      "verification": {
        "kind": "capacity",
        "capacity": 8,
        "width": 8,
        "offset": 0
      }
    },
    {
      "id": "M06-V06",
      "group": "M06",
      "sourceQuestion": 6,
      "sourcePage": 2,
      "variant": 6,
      "origin": "variant",
      "type": "mcq",
      "question": "For an input token longer than the field width, how many input characters can this call store, excluding the null terminator?",
      "options": [
        "8",
        "Unknown",
        "7",
        "9"
      ],
      "correct": 0,
      "explanation": "The field width limits this conversion to 8 input characters, followed by a null terminator. The destination has enough room; remaining token characters stay unread.",
      "code": "char buffer[9];\nscanf(\"%8s\", buffer);",
      "verification": {
        "kind": "capacity",
        "capacity": 9,
        "width": 8,
        "offset": 0
      }
    },
    {
      "id": "M06-V07",
      "group": "M06",
      "sourceQuestion": 6,
      "sourcePage": 2,
      "variant": 7,
      "origin": "variant",
      "type": "mcq",
      "question": "For an input token longer than the field width, how many input characters can this call store, excluding the null terminator?",
      "options": [
        "12",
        "13",
        "20",
        "18"
      ],
      "correct": 0,
      "explanation": "The field width limits this conversion to 12 input characters, followed by a null terminator. The destination has enough room; remaining token characters stay unread.",
      "code": "char buffer[20];\nscanf(\"%12s\", buffer);",
      "verification": {
        "kind": "capacity",
        "capacity": 20,
        "width": 12,
        "offset": 0
      }
    },
    {
      "id": "M06-V08",
      "group": "M06",
      "sourceQuestion": 6,
      "sourcePage": 2,
      "variant": 8,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the maximum number of non-whitespace input characters this destination can safely store as a C string?",
      "options": [
        "8",
        "12",
        "9",
        "7"
      ],
      "correct": 0,
      "explanation": "The writable destination has 9 bytes, so 8 are available for input characters and one for the null terminator.",
      "code": "char buffer[12];\nscanf(\"%s\", buffer + 3);",
      "verification": {
        "kind": "capacity",
        "capacity": 12,
        "width": null,
        "offset": 3
      }
    },
    {
      "id": "M06-V09",
      "group": "M06",
      "sourceQuestion": 6,
      "sourcePage": 2,
      "variant": 9,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the maximum number of non-whitespace input characters this destination can safely store as a C string?",
      "options": [
        "16",
        "9",
        "8",
        "7"
      ],
      "correct": 2,
      "explanation": "The writable destination has 9 bytes, so 8 are available for input characters and one for the null terminator.",
      "code": "char buffer[16];\nscanf(\"%s\", buffer + 7);",
      "verification": {
        "kind": "capacity",
        "capacity": 16,
        "width": null,
        "offset": 7
      }
    },
    {
      "id": "M06-V10",
      "group": "M06",
      "sourceQuestion": 6,
      "sourcePage": 2,
      "variant": 10,
      "origin": "variant",
      "type": "mcq",
      "question": "For an input token longer than the field width, how many input characters can this call store, excluding the null terminator?",
      "options": [
        "32",
        "10",
        "30",
        "11"
      ],
      "correct": 1,
      "explanation": "The field width limits this conversion to 10 input characters, followed by a null terminator. The destination has enough room; remaining token characters stay unread.",
      "code": "char buffer[32];\nscanf(\"%10s\", buffer);",
      "verification": {
        "kind": "capacity",
        "capacity": 32,
        "width": 10,
        "offset": 0
      }
    },
    {
      "id": "M07-O",
      "group": "M07",
      "sourceQuestion": 7,
      "sourcePage": 2,
      "variant": 0,
      "origin": "original",
      "type": "mcq",
      "question": "The following function is passed the arguments 0xcafedead and 3. The return value is:",
      "options": [
        "0",
        "13",
        "14",
        "15"
      ],
      "correct": 1,
      "explanation": "i * 4 is 12. Shifting right by 12 places puts the fourth nibble from the right (D) into the low position, and 0xF isolates it. Hexadecimal D is decimal 13.",
      "code": "int mystery(int b, int i) {\n    return (b >> (i * 4)) & 0xf;\n}",
      "note": "Assume 32-bit two’s-complement int, conversion of the argument preserves its low 32 bits, and signed right shift is arithmetic. These are machine assumptions, not universal C17 guarantees.",
      "verification": {
        "kind": "field",
        "value": 3405700781,
        "shift": 12,
        "mask": 15
      }
    },
    {
      "id": "M07-V01",
      "group": "M07",
      "sourceQuestion": 7,
      "sourcePage": 2,
      "variant": 1,
      "origin": "variant",
      "type": "mcq",
      "question": "The function is called as mystery(0xA17C03E9u, 0). What value is returned?",
      "options": [
        "0",
        "14",
        "10",
        "9"
      ],
      "correct": 3,
      "explanation": "The shift is 0 × 4 = 0 bits. Nibble index 0, counting from zero on the right, is 9; masking with 0xF returns decimal 9.",
      "code": "unsigned int mystery(unsigned int b, int i) {\n    return (b >> (i * 4)) & 0xFu;\n}",
      "verification": {
        "kind": "field",
        "value": 2709259241,
        "shift": 0,
        "mask": 15
      }
    },
    {
      "id": "M07-V02",
      "group": "M07",
      "sourceQuestion": 7,
      "sourcePage": 2,
      "variant": 2,
      "origin": "variant",
      "type": "mcq",
      "question": "The function is called as mystery(0xA17C03E9u, 7). What value is returned?",
      "options": [
        "10",
        "7",
        "11",
        "9"
      ],
      "correct": 0,
      "explanation": "The shift is 7 × 4 = 28 bits. Nibble index 7, counting from zero on the right, is A; masking with 0xF returns decimal 10.",
      "code": "unsigned int mystery(unsigned int b, int i) {\n    return (b >> (i * 4)) & 0xFu;\n}",
      "verification": {
        "kind": "field",
        "value": 2709259241,
        "shift": 28,
        "mask": 15
      }
    },
    {
      "id": "M07-V03",
      "group": "M07",
      "sourceQuestion": 7,
      "sourcePage": 2,
      "variant": 3,
      "origin": "variant",
      "type": "mcq",
      "question": "The function is called as mystery(0x08F2B640u, 3). What value is returned?",
      "options": [
        "11",
        "2",
        "12",
        "3"
      ],
      "correct": 0,
      "explanation": "The shift is 3 × 4 = 12 bits. Nibble index 3, counting from zero on the right, is B; masking with 0xF returns decimal 11.",
      "code": "unsigned int mystery(unsigned int b, int i) {\n    return (b >> (i * 4)) & 0xFu;\n}",
      "verification": {
        "kind": "field",
        "value": 150124096,
        "shift": 12,
        "mask": 15
      }
    },
    {
      "id": "M07-V04",
      "group": "M07",
      "sourceQuestion": 7,
      "sourcePage": 2,
      "variant": 4,
      "origin": "variant",
      "type": "mcq",
      "question": "The function is called as mystery(0xDEAD102Fu, 4). What value is returned?",
      "options": [
        "14",
        "10",
        "13",
        "4"
      ],
      "correct": 2,
      "explanation": "The shift is 4 × 4 = 16 bits. Nibble index 4, counting from zero on the right, is D; masking with 0xF returns decimal 13.",
      "code": "unsigned int mystery(unsigned int b, int i) {\n    return (b >> (i * 4)) & 0xFu;\n}",
      "verification": {
        "kind": "field",
        "value": 3735883823,
        "shift": 16,
        "mask": 15
      }
    },
    {
      "id": "M07-V05",
      "group": "M07",
      "sourceQuestion": 7,
      "sourcePage": 2,
      "variant": 5,
      "origin": "variant",
      "type": "mcq",
      "question": "The function is called as mystery(0x7F0081C3u, 2). What value is returned?",
      "options": [
        "1",
        "8",
        "2",
        "9"
      ],
      "correct": 0,
      "explanation": "The shift is 2 × 4 = 8 bits. Nibble index 2, counting from zero on the right, is 1; masking with 0xF returns decimal 1.",
      "code": "unsigned int mystery(unsigned int b, int i) {\n    return (b >> (i * 4)) & 0xFu;\n}",
      "verification": {
        "kind": "field",
        "value": 2130739651,
        "shift": 8,
        "mask": 15
      }
    },
    {
      "id": "M07-V06",
      "group": "M07",
      "sourceQuestion": 7,
      "sourcePage": 2,
      "variant": 6,
      "origin": "variant",
      "type": "mcq",
      "question": "The function is called as mystery(0x80000001u, 6). What value is returned?",
      "options": [
        "1",
        "0",
        "8",
        "6"
      ],
      "correct": 1,
      "explanation": "The shift is 6 × 4 = 24 bits. Nibble index 6, counting from zero on the right, is 0; masking with 0xF returns decimal 0.",
      "code": "unsigned int mystery(unsigned int b, int i) {\n    return (b >> (i * 4)) & 0xFu;\n}",
      "verification": {
        "kind": "field",
        "value": 2147483649,
        "shift": 24,
        "mask": 15
      }
    },
    {
      "id": "M07-V07",
      "group": "M07",
      "sourceQuestion": 7,
      "sourcePage": 2,
      "variant": 7,
      "origin": "variant",
      "type": "mcq",
      "question": "The function is called as mystery(0x13579BDFu, 5). What value is returned?",
      "options": [
        "6",
        "3",
        "5",
        "13"
      ],
      "correct": 2,
      "explanation": "The shift is 5 × 4 = 20 bits. Nibble index 5, counting from zero on the right, is 5; masking with 0xF returns decimal 5.",
      "code": "unsigned int mystery(unsigned int b, int i) {\n    return (b >> (i * 4)) & 0xFu;\n}",
      "verification": {
        "kind": "field",
        "value": 324508639,
        "shift": 20,
        "mask": 15
      }
    },
    {
      "id": "M07-V08",
      "group": "M07",
      "sourceQuestion": 7,
      "sourcePage": 2,
      "variant": 8,
      "origin": "variant",
      "type": "mcq",
      "question": "The function is called as mystery(0x2468ACE0u, 1). What value is returned?",
      "options": [
        "12",
        "15",
        "14",
        "1"
      ],
      "correct": 2,
      "explanation": "The shift is 1 × 4 = 4 bits. Nibble index 1, counting from zero on the right, is E; masking with 0xF returns decimal 14.",
      "code": "unsigned int mystery(unsigned int b, int i) {\n    return (b >> (i * 4)) & 0xFu;\n}",
      "verification": {
        "kind": "field",
        "value": 610839776,
        "shift": 4,
        "mask": 15
      }
    },
    {
      "id": "M07-V09",
      "group": "M07",
      "sourceQuestion": 7,
      "sourcePage": 2,
      "variant": 9,
      "origin": "variant",
      "type": "mcq",
      "question": "The function is called as mystery(0x00FF10A5u, 6). What value is returned?",
      "options": [
        "8",
        "6",
        "0",
        "1"
      ],
      "correct": 2,
      "explanation": "The shift is 6 × 4 = 24 bits. Nibble index 6, counting from zero on the right, is 0; masking with 0xF returns decimal 0.",
      "code": "unsigned int mystery(unsigned int b, int i) {\n    return (b >> (i * 4)) & 0xFu;\n}",
      "verification": {
        "kind": "field",
        "value": 16715941,
        "shift": 24,
        "mask": 15
      }
    },
    {
      "id": "M07-V10",
      "group": "M07",
      "sourceQuestion": 7,
      "sourcePage": 2,
      "variant": 10,
      "origin": "variant",
      "type": "mcq",
      "question": "The function is called as mystery(0xF00DC0DEu, 4). What value is returned?",
      "options": [
        "13",
        "14",
        "0",
        "4"
      ],
      "correct": 0,
      "explanation": "The shift is 4 × 4 = 16 bits. Nibble index 4, counting from zero on the right, is D; masking with 0xF returns decimal 13.",
      "code": "unsigned int mystery(unsigned int b, int i) {\n    return (b >> (i * 4)) & 0xFu;\n}",
      "verification": {
        "kind": "field",
        "value": 4027433182,
        "shift": 16,
        "mask": 15
      }
    },
    {
      "id": "M08-O",
      "group": "M08",
      "sourceQuestion": 8,
      "sourcePage": 2,
      "variant": 0,
      "origin": "original",
      "type": "mcq",
      "question": "Suppose 0xcafed00d represents a signed int in little endian representation. Which of the following are true?",
      "options": [
        "The integer is negative and odd.",
        "The integer is positive and odd.",
        "The integer is negative and even.",
        "The integer is positive and even."
      ],
      "correct": 0,
      "explanation": "For a 32-bit two’s-complement interpretation, the top bit of C is 1, so the value is negative. The low hexadecimal digit D is odd. Little endian affects byte layout, not either conclusion.",
      "note": "Interpret the given hexadecimal number as a 32-bit two’s-complement value, not as a left-to-right list of bytes at increasing addresses.",
      "verification": {
        "kind": "signParity",
        "value": 3405697037,
        "width": 32
      }
    },
    {
      "id": "M08-V01",
      "group": "M08",
      "sourceQuestion": 8,
      "sourcePage": 2,
      "variant": 1,
      "origin": "variant",
      "type": "mcq",
      "question": "The hexadecimal value 0x7ABCDE01 is interpreted as a 32-bit two’s-complement signed int on a little-endian machine. Which statement is true?",
      "options": [
        "The integer is positive and odd.",
        "The integer is negative and even.",
        "The integer is positive and even.",
        "The integer is negative and odd."
      ],
      "correct": 0,
      "explanation": "The top bit is 0, so the value is positive. The low bit is 1, so it is odd. Byte order does not change these properties.",
      "verification": {
        "kind": "signParity",
        "value": 2059197953,
        "width": 32
      }
    },
    {
      "id": "M08-V02",
      "group": "M08",
      "sourceQuestion": 8,
      "sourcePage": 2,
      "variant": 2,
      "origin": "variant",
      "type": "mcq",
      "question": "The hexadecimal value 0x80000000 is interpreted as a 32-bit two’s-complement signed int on a big-endian machine. Which statement is true?",
      "options": [
        "The integer is negative and even.",
        "The integer is positive and odd.",
        "The integer is negative and odd.",
        "The integer is positive and even."
      ],
      "correct": 0,
      "explanation": "The top bit is 1, so the value is negative. The low bit is 0, so it is even. Byte order does not change these properties.",
      "verification": {
        "kind": "signParity",
        "value": 2147483648,
        "width": 32
      }
    },
    {
      "id": "M08-V03",
      "group": "M08",
      "sourceQuestion": 8,
      "sourcePage": 2,
      "variant": 3,
      "origin": "variant",
      "type": "mcq",
      "question": "The hexadecimal value 0xF1234567 is interpreted as a 32-bit two’s-complement signed int on a little-endian machine. Which statement is true?",
      "options": [
        "The integer is negative and even.",
        "The integer is positive and even.",
        "The integer is positive and odd.",
        "The integer is negative and odd."
      ],
      "correct": 3,
      "explanation": "The top bit is 1, so the value is negative. The low bit is 1, so it is odd. Byte order does not change these properties.",
      "verification": {
        "kind": "signParity",
        "value": 4045620583,
        "width": 32
      }
    },
    {
      "id": "M08-V04",
      "group": "M08",
      "sourceQuestion": 8,
      "sourcePage": 2,
      "variant": 4,
      "origin": "variant",
      "type": "mcq",
      "question": "The hexadecimal value 0x12345678 is interpreted as a 32-bit two’s-complement signed int on a big-endian machine. Which statement is true?",
      "options": [
        "The integer is positive and odd.",
        "The integer is positive and even.",
        "The integer is negative and even.",
        "The integer is negative and odd."
      ],
      "correct": 1,
      "explanation": "The top bit is 0, so the value is positive. The low bit is 0, so it is even. Byte order does not change these properties.",
      "verification": {
        "kind": "signParity",
        "value": 305419896,
        "width": 32
      }
    },
    {
      "id": "M08-V05",
      "group": "M08",
      "sourceQuestion": 8,
      "sourcePage": 2,
      "variant": 5,
      "origin": "variant",
      "type": "mcq",
      "question": "The hexadecimal value 0x00000100 is interpreted as a 32-bit two’s-complement signed int on a little-endian machine. Which statement is true?",
      "options": [
        "The integer is negative and odd.",
        "The integer is positive and odd.",
        "The integer is negative and even.",
        "The integer is positive and even."
      ],
      "correct": 3,
      "explanation": "The top bit is 0, so the value is positive. The low bit is 0, so it is even. Byte order does not change these properties.",
      "verification": {
        "kind": "signParity",
        "value": 256,
        "width": 32
      }
    },
    {
      "id": "M08-V06",
      "group": "M08",
      "sourceQuestion": 8,
      "sourcePage": 2,
      "variant": 6,
      "origin": "variant",
      "type": "mcq",
      "question": "The hexadecimal value 0xFFFFFFFE is interpreted as a 32-bit two’s-complement signed int on a little-endian machine. Which statement is true?",
      "options": [
        "The integer is positive and even.",
        "The integer is negative and even.",
        "The integer is negative and odd.",
        "The integer is positive and odd."
      ],
      "correct": 1,
      "explanation": "The top bit is 1, so the value is negative. The low bit is 0, so it is even. Byte order does not change these properties.",
      "verification": {
        "kind": "signParity",
        "value": 4294967294,
        "width": 32
      }
    },
    {
      "id": "M08-V07",
      "group": "M08",
      "sourceQuestion": 8,
      "sourcePage": 2,
      "variant": 7,
      "origin": "variant",
      "type": "mcq",
      "question": "The hexadecimal value 0x7FFFFFFF is interpreted as a 32-bit two’s-complement signed int on a big-endian machine. Which statement is true?",
      "options": [
        "The integer is negative and odd.",
        "The integer is positive and even.",
        "The integer is negative and even.",
        "The integer is positive and odd."
      ],
      "correct": 3,
      "explanation": "The top bit is 0, so the value is positive. The low bit is 1, so it is odd. Byte order does not change these properties.",
      "verification": {
        "kind": "signParity",
        "value": 2147483647,
        "width": 32
      }
    },
    {
      "id": "M08-V08",
      "group": "M08",
      "sourceQuestion": 8,
      "sourcePage": 2,
      "variant": 8,
      "origin": "variant",
      "type": "mcq",
      "question": "The hexadecimal value 0xA0000001 is interpreted as a 32-bit two’s-complement signed int on a big-endian machine. Which statement is true?",
      "options": [
        "The integer is positive and even.",
        "The integer is positive and odd.",
        "The integer is negative and even.",
        "The integer is negative and odd."
      ],
      "correct": 3,
      "explanation": "The top bit is 1, so the value is negative. The low bit is 1, so it is odd. Byte order does not change these properties.",
      "verification": {
        "kind": "signParity",
        "value": 2684354561,
        "width": 32
      }
    },
    {
      "id": "M08-V09",
      "group": "M08",
      "sourceQuestion": 8,
      "sourcePage": 2,
      "variant": 9,
      "origin": "variant",
      "type": "mcq",
      "question": "The hexadecimal value 0x80000002 is interpreted as a 32-bit two’s-complement signed int on a little-endian machine. Which statement is true?",
      "options": [
        "The integer is positive and odd.",
        "The integer is negative and even.",
        "The integer is negative and odd.",
        "The integer is positive and even."
      ],
      "correct": 1,
      "explanation": "The top bit is 1, so the value is negative. The low bit is 0, so it is even. Byte order does not change these properties.",
      "verification": {
        "kind": "signParity",
        "value": 2147483650,
        "width": 32
      }
    },
    {
      "id": "M08-V10",
      "group": "M08",
      "sourceQuestion": 8,
      "sourcePage": 2,
      "variant": 10,
      "origin": "variant",
      "type": "mcq",
      "question": "The hexadecimal value 0x00000003 is interpreted as a 32-bit two’s-complement signed int on a little-endian machine. Which statement is true?",
      "options": [
        "The integer is positive and odd.",
        "The integer is negative and odd.",
        "The integer is positive and even.",
        "The integer is negative and even."
      ],
      "correct": 0,
      "explanation": "The top bit is 0, so the value is positive. The low bit is 1, so it is odd. Byte order does not change these properties.",
      "verification": {
        "kind": "signParity",
        "value": 3,
        "width": 32
      }
    },
    {
      "id": "M09-O",
      "group": "M09",
      "sourceQuestion": 9,
      "sourcePage": 2,
      "variant": 0,
      "origin": "original",
      "type": "mcq",
      "question": "Consider the 4-bit string s = 0b1011 (0b indicates binary). Which of the values below is NOT a valid interpretation of the bit-string in the formats seen in class (unsigned, sign-mag., 2sC)?",
      "options": [
        "-5",
        "11",
        "-3",
        "-4"
      ],
      "correct": 3,
      "explanation": "Unsigned gives 11. Sign-magnitude uses sign 1 with magnitude 011, giving -3. Two’s complement gives 11 - 16 = -5. Thus -4 is not one of those interpretations.",
      "verification": {
        "kind": "interpretations",
        "value": 11,
        "width": 4
      }
    },
    {
      "id": "M09-V01",
      "group": "M09",
      "sourceQuestion": 9,
      "sourcePage": 2,
      "variant": 1,
      "origin": "variant",
      "type": "mcq",
      "question": "The 4-bit string is 0b1001. Which decimal value is NOT an interpretation under unsigned, sign-magnitude, or two’s-complement encoding?",
      "options": [
        "9",
        "-7",
        "-1",
        "-6"
      ],
      "correct": 3,
      "explanation": "Unsigned: 9. Sign-magnitude: -1. Two’s complement: 9 - 16 = -7. The remaining option, -6, is not represented by these bits under the listed formats.",
      "verification": {
        "kind": "interpretations",
        "value": 9,
        "width": 4
      }
    },
    {
      "id": "M09-V02",
      "group": "M09",
      "sourceQuestion": 9,
      "sourcePage": 2,
      "variant": 2,
      "origin": "variant",
      "type": "mcq",
      "question": "The 4-bit string is 0b1010. Which decimal value is NOT an interpretation under unsigned, sign-magnitude, or two’s-complement encoding?",
      "options": [
        "10",
        "-6",
        "-4",
        "-2"
      ],
      "correct": 2,
      "explanation": "Unsigned: 10. Sign-magnitude: -2. Two’s complement: 10 - 16 = -6. The remaining option, -4, is not represented by these bits under the listed formats.",
      "verification": {
        "kind": "interpretations",
        "value": 10,
        "width": 4
      }
    },
    {
      "id": "M09-V03",
      "group": "M09",
      "sourceQuestion": 9,
      "sourcePage": 2,
      "variant": 3,
      "origin": "variant",
      "type": "mcq",
      "question": "The 4-bit string is 0b1101. Which decimal value is NOT an interpretation under unsigned, sign-magnitude, or two’s-complement encoding?",
      "options": [
        "-6",
        "-5",
        "-3",
        "13"
      ],
      "correct": 0,
      "explanation": "Unsigned: 13. Sign-magnitude: -5. Two’s complement: 13 - 16 = -3. The remaining option, -6, is not represented by these bits under the listed formats.",
      "verification": {
        "kind": "interpretations",
        "value": 13,
        "width": 4
      }
    },
    {
      "id": "M09-V04",
      "group": "M09",
      "sourceQuestion": 9,
      "sourcePage": 2,
      "variant": 4,
      "origin": "variant",
      "type": "mcq",
      "question": "The 4-bit string is 0b1110. Which decimal value is NOT an interpretation under unsigned, sign-magnitude, or two’s-complement encoding?",
      "options": [
        "14",
        "-3",
        "-6",
        "-2"
      ],
      "correct": 1,
      "explanation": "Unsigned: 14. Sign-magnitude: -6. Two’s complement: 14 - 16 = -2. The remaining option, -3, is not represented by these bits under the listed formats.",
      "verification": {
        "kind": "interpretations",
        "value": 14,
        "width": 4
      }
    },
    {
      "id": "M09-V05",
      "group": "M09",
      "sourceQuestion": 9,
      "sourcePage": 2,
      "variant": 5,
      "origin": "variant",
      "type": "mcq",
      "question": "The 4-bit string is 0b1111. Which decimal value is NOT an interpretation under unsigned, sign-magnitude, or two’s-complement encoding?",
      "options": [
        "-7",
        "15",
        "-1",
        "-2"
      ],
      "correct": 3,
      "explanation": "Unsigned: 15. Sign-magnitude: -7. Two’s complement: 15 - 16 = -1. The remaining option, -2, is not represented by these bits under the listed formats.",
      "verification": {
        "kind": "interpretations",
        "value": 15,
        "width": 4
      }
    },
    {
      "id": "M09-V06",
      "group": "M09",
      "sourceQuestion": 9,
      "sourcePage": 2,
      "variant": 6,
      "origin": "variant",
      "type": "mcq",
      "question": "The 5-bit string is 0b10001. Which decimal value is NOT an interpretation under unsigned, sign-magnitude, or two’s-complement encoding?",
      "options": [
        "17",
        "-14",
        "-15",
        "-1"
      ],
      "correct": 1,
      "explanation": "Unsigned: 17. Sign-magnitude: -1. Two’s complement: 17 - 32 = -15. The remaining option, -14, is not represented by these bits under the listed formats.",
      "verification": {
        "kind": "interpretations",
        "value": 17,
        "width": 5
      }
    },
    {
      "id": "M09-V07",
      "group": "M09",
      "sourceQuestion": 9,
      "sourcePage": 2,
      "variant": 7,
      "origin": "variant",
      "type": "mcq",
      "question": "The 5-bit string is 0b10101. Which decimal value is NOT an interpretation under unsigned, sign-magnitude, or two’s-complement encoding?",
      "options": [
        "21",
        "-6",
        "-5",
        "-11"
      ],
      "correct": 1,
      "explanation": "Unsigned: 21. Sign-magnitude: -5. Two’s complement: 21 - 32 = -11. The remaining option, -6, is not represented by these bits under the listed formats.",
      "verification": {
        "kind": "interpretations",
        "value": 21,
        "width": 5
      }
    },
    {
      "id": "M09-V08",
      "group": "M09",
      "sourceQuestion": 9,
      "sourcePage": 2,
      "variant": 8,
      "origin": "variant",
      "type": "mcq",
      "question": "The 5-bit string is 0b11011. Which decimal value is NOT an interpretation under unsigned, sign-magnitude, or two’s-complement encoding?",
      "options": [
        "27",
        "-5",
        "-11",
        "-4"
      ],
      "correct": 3,
      "explanation": "Unsigned: 27. Sign-magnitude: -11. Two’s complement: 27 - 32 = -5. The remaining option, -4, is not represented by these bits under the listed formats.",
      "verification": {
        "kind": "interpretations",
        "value": 27,
        "width": 5
      }
    },
    {
      "id": "M09-V09",
      "group": "M09",
      "sourceQuestion": 9,
      "sourcePage": 2,
      "variant": 9,
      "origin": "variant",
      "type": "mcq",
      "question": "The 8-bit string is 0b10000001. Which decimal value is NOT an interpretation under unsigned, sign-magnitude, or two’s-complement encoding?",
      "options": [
        "-127",
        "-126",
        "129",
        "-1"
      ],
      "correct": 1,
      "explanation": "Unsigned: 129. Sign-magnitude: -1. Two’s complement: 129 - 256 = -127. The remaining option, -126, is not represented by these bits under the listed formats.",
      "verification": {
        "kind": "interpretations",
        "value": 129,
        "width": 8
      }
    },
    {
      "id": "M09-V10",
      "group": "M09",
      "sourceQuestion": 9,
      "sourcePage": 2,
      "variant": 10,
      "origin": "variant",
      "type": "mcq",
      "question": "The 8-bit string is 0b11111110. Which decimal value is NOT an interpretation under unsigned, sign-magnitude, or two’s-complement encoding?",
      "options": [
        "-126",
        "-2",
        "254",
        "-3"
      ],
      "correct": 3,
      "explanation": "Unsigned: 254. Sign-magnitude: -126. Two’s complement: 254 - 256 = -2. The remaining option, -3, is not represented by these bits under the listed formats.",
      "verification": {
        "kind": "interpretations",
        "value": 254,
        "width": 8
      }
    },
    {
      "id": "M10-O",
      "group": "M10",
      "sourceQuestion": 10,
      "sourcePage": 3,
      "variant": 0,
      "origin": "original",
      "type": "mcq",
      "question": "Which of the following 8-bit numbers has the same signed value as the 4-bit number 0xC?",
      "options": [
        "0x0C",
        "0x7C",
        "0x8C",
        "0xFC"
      ],
      "correct": 3,
      "explanation": "In four-bit two’s complement, 1100 is -4. Repeating its sign bit gives 11111100, which is 0xFC and remains -4 in eight bits.",
      "note": "Use two’s-complement encoding at both widths.",
      "verification": {
        "kind": "extend",
        "value": 12,
        "from": 4,
        "to": 8
      }
    },
    {
      "id": "M10-V01",
      "group": "M10",
      "sourceQuestion": 10,
      "sourcePage": 3,
      "variant": 1,
      "origin": "variant",
      "type": "mcq",
      "question": "Which 8-bit two’s-complement pattern preserves the signed value of the 4-bit pattern 0x9?",
      "options": [
        "0xE9",
        "0x89",
        "0xF9",
        "0x09"
      ],
      "correct": 2,
      "explanation": "The original signed value is -7. Extend the sign bit (1) through the added high positions; the result is 0xF9.",
      "verification": {
        "kind": "extend",
        "value": 9,
        "from": 4,
        "to": 8
      }
    },
    {
      "id": "M10-V02",
      "group": "M10",
      "sourceQuestion": 10,
      "sourcePage": 3,
      "variant": 2,
      "origin": "variant",
      "type": "mcq",
      "question": "Which 8-bit two’s-complement pattern preserves the signed value of the 4-bit pattern 0x7?",
      "options": [
        "0x87",
        "0x07",
        "0x00",
        "0x17"
      ],
      "correct": 1,
      "explanation": "The original signed value is 7. Extend the sign bit (0) through the added high positions; the result is 0x07.",
      "verification": {
        "kind": "extend",
        "value": 7,
        "from": 4,
        "to": 8
      }
    },
    {
      "id": "M10-V03",
      "group": "M10",
      "sourceQuestion": 10,
      "sourcePage": 3,
      "variant": 3,
      "origin": "variant",
      "type": "mcq",
      "question": "Which 8-bit two’s-complement pattern preserves the signed value of the 4-bit pattern 0xF?",
      "options": [
        "0x0F",
        "0xEF",
        "0xFF",
        "0x8F"
      ],
      "correct": 2,
      "explanation": "The original signed value is -1. Extend the sign bit (1) through the added high positions; the result is 0xFF.",
      "verification": {
        "kind": "extend",
        "value": 15,
        "from": 4,
        "to": 8
      }
    },
    {
      "id": "M10-V04",
      "group": "M10",
      "sourceQuestion": 10,
      "sourcePage": 3,
      "variant": 4,
      "origin": "variant",
      "type": "mcq",
      "question": "Which 8-bit two’s-complement pattern preserves the signed value of the 4-bit pattern 0x8?",
      "options": [
        "0x88",
        "0xF8",
        "0x08",
        "0xE8"
      ],
      "correct": 1,
      "explanation": "The original signed value is -8. Extend the sign bit (1) through the added high positions; the result is 0xF8.",
      "verification": {
        "kind": "extend",
        "value": 8,
        "from": 4,
        "to": 8
      }
    },
    {
      "id": "M10-V05",
      "group": "M10",
      "sourceQuestion": 10,
      "sourcePage": 3,
      "variant": 5,
      "origin": "variant",
      "type": "mcq",
      "question": "Which 16-bit two’s-complement pattern preserves the signed value of the 8-bit pattern 0xA5?",
      "options": [
        "0xFEA5",
        "0x00A5",
        "0xFFA5",
        "0x80A5"
      ],
      "correct": 2,
      "explanation": "The original signed value is -91. Extend the sign bit (1) through the added high positions; the result is 0xFFA5.",
      "verification": {
        "kind": "extend",
        "value": 165,
        "from": 8,
        "to": 16
      }
    },
    {
      "id": "M10-V06",
      "group": "M10",
      "sourceQuestion": 10,
      "sourcePage": 3,
      "variant": 6,
      "origin": "variant",
      "type": "mcq",
      "question": "Which 16-bit two’s-complement pattern preserves the signed value of the 8-bit pattern 0x7E?",
      "options": [
        "0x007E",
        "0x017E",
        "0x0000",
        "0x807E"
      ],
      "correct": 0,
      "explanation": "The original signed value is 126. Extend the sign bit (0) through the added high positions; the result is 0x007E.",
      "verification": {
        "kind": "extend",
        "value": 126,
        "from": 8,
        "to": 16
      }
    },
    {
      "id": "M10-V07",
      "group": "M10",
      "sourceQuestion": 10,
      "sourcePage": 3,
      "variant": 7,
      "origin": "variant",
      "type": "mcq",
      "question": "Which 16-bit two’s-complement pattern preserves the signed value of the 8-bit pattern 0x80?",
      "options": [
        "0x8080",
        "0x0080",
        "0xFF80",
        "0xFE80"
      ],
      "correct": 2,
      "explanation": "The original signed value is -128. Extend the sign bit (1) through the added high positions; the result is 0xFF80.",
      "verification": {
        "kind": "extend",
        "value": 128,
        "from": 8,
        "to": 16
      }
    },
    {
      "id": "M10-V08",
      "group": "M10",
      "sourceQuestion": 10,
      "sourcePage": 3,
      "variant": 8,
      "origin": "variant",
      "type": "mcq",
      "question": "Which 16-bit two’s-complement pattern preserves the signed value of the 8-bit pattern 0xFF?",
      "options": [
        "0xFFFF",
        "0xFEFF",
        "0x00FF",
        "0x80FF"
      ],
      "correct": 0,
      "explanation": "The original signed value is -1. Extend the sign bit (1) through the added high positions; the result is 0xFFFF.",
      "verification": {
        "kind": "extend",
        "value": 255,
        "from": 8,
        "to": 16
      }
    },
    {
      "id": "M10-V09",
      "group": "M10",
      "sourceQuestion": 10,
      "sourcePage": 3,
      "variant": 9,
      "origin": "variant",
      "type": "mcq",
      "question": "Which 16-bit two’s-complement pattern preserves the signed value of the 4-bit pattern 0xB?",
      "options": [
        "0x800B",
        "0x000B",
        "0xFFFB",
        "0xFFEB"
      ],
      "correct": 2,
      "explanation": "The original signed value is -5. Extend the sign bit (1) through the added high positions; the result is 0xFFFB.",
      "verification": {
        "kind": "extend",
        "value": 11,
        "from": 4,
        "to": 16
      }
    },
    {
      "id": "M10-V10",
      "group": "M10",
      "sourceQuestion": 10,
      "sourcePage": 3,
      "variant": 10,
      "origin": "variant",
      "type": "mcq",
      "question": "Which 32-bit two’s-complement pattern preserves the signed value of the 8-bit pattern 0xD2?",
      "options": [
        "0x000000D2",
        "0x800000D2",
        "0xFFFFFFD2",
        "0xFFFFFED2"
      ],
      "correct": 2,
      "explanation": "The original signed value is -46. Extend the sign bit (1) through the added high positions; the result is 0xFFFFFFD2.",
      "verification": {
        "kind": "extend",
        "value": 210,
        "from": 8,
        "to": 32
      }
    },
    {
      "id": "M11-O",
      "group": "M11",
      "sourceQuestion": 11,
      "sourcePage": 3,
      "variant": 0,
      "origin": "original",
      "type": "mcq",
      "question": "Consider a signed char x. The value of x that makes the expression x != (x >> 2) << 2 true is:",
      "options": [
        "12",
        "20",
        "22",
        "] 32"
      ],
      "correct": 2,
      "explanation": "All listed numeric candidates are nonnegative. Shifting right and back left removes the low two bits. 22 is 10110, so it becomes 10100 = 20 and differs; 12, 20, and 32 are multiples of four. The stray bracket before 32 is a PDF typo.",
      "verification": {
        "kind": "discard",
        "shift": 2,
        "relation": "!="
      }
    },
    {
      "id": "M11-V01",
      "group": "M11",
      "sourceQuestion": 11,
      "sourcePage": 3,
      "variant": 1,
      "origin": "variant",
      "type": "mcq",
      "question": "For a signed char x with one of the nonnegative values listed, which value makes x != ((x >> 1) << 1) true?",
      "options": [
        "18",
        "57",
        "80",
        "34"
      ],
      "correct": 1,
      "explanation": "The two shifts discard the low 1 bits. The reconstructed value for 57 is 56. Equality holds exactly for multiples of 2; this question asks for inequality.",
      "verification": {
        "kind": "discard",
        "shift": 1,
        "relation": "!="
      }
    },
    {
      "id": "M11-V02",
      "group": "M11",
      "sourceQuestion": 11,
      "sourcePage": 3,
      "variant": 2,
      "origin": "variant",
      "type": "mcq",
      "question": "For a signed char x with one of the nonnegative values listed, which value makes x != ((x >> 2) << 2) true?",
      "options": [
        "25",
        "64",
        "16",
        "44"
      ],
      "correct": 0,
      "explanation": "The two shifts discard the low 2 bits. The reconstructed value for 25 is 24. Equality holds exactly for multiples of 4; this question asks for inequality.",
      "verification": {
        "kind": "discard",
        "shift": 2,
        "relation": "!="
      }
    },
    {
      "id": "M11-V03",
      "group": "M11",
      "sourceQuestion": 11,
      "sourcePage": 3,
      "variant": 3,
      "origin": "variant",
      "type": "mcq",
      "question": "For a signed char x with one of the nonnegative values listed, which value makes x != ((x >> 3) << 3) true?",
      "options": [
        "24",
        "58",
        "96",
        "8"
      ],
      "correct": 1,
      "explanation": "The two shifts discard the low 3 bits. The reconstructed value for 58 is 56. Equality holds exactly for multiples of 8; this question asks for inequality.",
      "verification": {
        "kind": "discard",
        "shift": 3,
        "relation": "!="
      }
    },
    {
      "id": "M11-V04",
      "group": "M11",
      "sourceQuestion": 11,
      "sourcePage": 3,
      "variant": 4,
      "origin": "variant",
      "type": "mcq",
      "question": "For a signed char x with one of the nonnegative values listed, which value makes x != ((x >> 4) << 4) true?",
      "options": [
        "80",
        "95",
        "32",
        "16"
      ],
      "correct": 1,
      "explanation": "The two shifts discard the low 4 bits. The reconstructed value for 95 is 80. Equality holds exactly for multiples of 16; this question asks for inequality.",
      "verification": {
        "kind": "discard",
        "shift": 4,
        "relation": "!="
      }
    },
    {
      "id": "M11-V05",
      "group": "M11",
      "sourceQuestion": 11,
      "sourcePage": 3,
      "variant": 5,
      "origin": "variant",
      "type": "mcq",
      "question": "For a signed char x with one of the nonnegative values listed, which value makes x == ((x >> 2) << 2) true?",
      "options": [
        "18",
        "28",
        "31",
        "13"
      ],
      "correct": 1,
      "explanation": "The two shifts discard the low 2 bits. The reconstructed value for 28 is 28. Equality holds exactly for multiples of 4; this question asks for equality.",
      "verification": {
        "kind": "discard",
        "shift": 2,
        "relation": "=="
      }
    },
    {
      "id": "M11-V06",
      "group": "M11",
      "sourceQuestion": 11,
      "sourcePage": 3,
      "variant": 6,
      "origin": "variant",
      "type": "mcq",
      "question": "For a signed char x with one of the nonnegative values listed, which value makes x == ((x >> 3) << 3) true?",
      "options": [
        "39",
        "17",
        "63",
        "32"
      ],
      "correct": 3,
      "explanation": "The two shifts discard the low 3 bits. The reconstructed value for 32 is 32. Equality holds exactly for multiples of 8; this question asks for equality.",
      "verification": {
        "kind": "discard",
        "shift": 3,
        "relation": "=="
      }
    },
    {
      "id": "M11-V07",
      "group": "M11",
      "sourceQuestion": 11,
      "sourcePage": 3,
      "variant": 7,
      "origin": "variant",
      "type": "mcq",
      "question": "For a signed char x with one of the nonnegative values listed, which value makes x == ((x >> 4) << 4) true?",
      "options": [
        "95",
        "31",
        "64",
        "15"
      ],
      "correct": 2,
      "explanation": "The two shifts discard the low 4 bits. The reconstructed value for 64 is 64. Equality holds exactly for multiples of 16; this question asks for equality.",
      "verification": {
        "kind": "discard",
        "shift": 4,
        "relation": "=="
      }
    },
    {
      "id": "M11-V08",
      "group": "M11",
      "sourceQuestion": 11,
      "sourcePage": 3,
      "variant": 8,
      "origin": "variant",
      "type": "mcq",
      "question": "For a signed char x with one of the nonnegative values listed, which value makes x == ((x >> 1) << 1) true?",
      "options": [
        "7",
        "44",
        "21",
        "63"
      ],
      "correct": 1,
      "explanation": "The two shifts discard the low 1 bits. The reconstructed value for 44 is 44. Equality holds exactly for multiples of 2; this question asks for equality.",
      "verification": {
        "kind": "discard",
        "shift": 1,
        "relation": "=="
      }
    },
    {
      "id": "M11-V09",
      "group": "M11",
      "sourceQuestion": 11,
      "sourcePage": 3,
      "variant": 9,
      "origin": "variant",
      "type": "mcq",
      "question": "For a signed char x with one of the nonnegative values listed, which value makes x != ((x >> 5) << 5) true?",
      "options": [
        "0",
        "32",
        "96",
        "65"
      ],
      "correct": 3,
      "explanation": "The two shifts discard the low 5 bits. The reconstructed value for 65 is 64. Equality holds exactly for multiples of 32; this question asks for inequality.",
      "verification": {
        "kind": "discard",
        "shift": 5,
        "relation": "!="
      }
    },
    {
      "id": "M11-V10",
      "group": "M11",
      "sourceQuestion": 11,
      "sourcePage": 3,
      "variant": 10,
      "origin": "variant",
      "type": "mcq",
      "question": "For a signed char x with one of the nonnegative values listed, which value makes x == ((x >> 3) << 3) true?",
      "options": [
        "7",
        "31",
        "15",
        "0"
      ],
      "correct": 3,
      "explanation": "The two shifts discard the low 3 bits. The reconstructed value for 0 is 0. Equality holds exactly for multiples of 8; this question asks for equality.",
      "verification": {
        "kind": "discard",
        "shift": 3,
        "relation": "=="
      }
    },
    {
      "id": "M12-O",
      "group": "M12",
      "sourceQuestion": 12,
      "sourcePage": 3,
      "variant": 0,
      "origin": "original",
      "type": "mcq",
      "question": "Given int x = 0x1A 2B 3C 4D, the value of (x >> 12) & 0xFF is:",
      "options": [
        "0x2B",
        "0xB3",
        "0xC3",
        "0xA2"
      ],
      "correct": 1,
      "explanation": "Reading the spaced hexadecimal digits as one value, 0x1A2B3C4D >> 12 is 0x1A2B3. The low eight bits are 0xB3. A 12-bit shift is three nibbles, not one byte.",
      "note": "The PDF spaces the hexadecimal digits for readability. Use the valid C literal 0x1A2B3C4D.",
      "verification": {
        "kind": "field",
        "value": 439041101,
        "shift": 12,
        "mask": 255
      }
    },
    {
      "id": "M12-V01",
      "group": "M12",
      "sourceQuestion": 12,
      "sourcePage": 3,
      "variant": 1,
      "origin": "variant",
      "type": "mcq",
      "question": "Given unsigned int x = 0x12345678u, what is the value of (x >> 4) & 0xFFu?",
      "options": [
        "0x78",
        "0x67",
        "0x66",
        "0x56"
      ],
      "correct": 1,
      "explanation": "After shifting by 4 bits the value is 0x1234567. Masking with 0xFF retains the selected low field, giving 0x67.",
      "verification": {
        "kind": "field",
        "value": 305419896,
        "shift": 4,
        "mask": 255
      }
    },
    {
      "id": "M12-V02",
      "group": "M12",
      "sourceQuestion": 12,
      "sourcePage": 3,
      "variant": 2,
      "origin": "variant",
      "type": "mcq",
      "question": "Given unsigned int x = 0xA1B2C3D4u, what is the value of (x >> 12) & 0xFFu?",
      "options": [
        "0xB2",
        "0x2D",
        "0xC3",
        "0x2C"
      ],
      "correct": 3,
      "explanation": "After shifting by 12 bits the value is 0xA1B2C. Masking with 0xFF retains the selected low field, giving 0x2C.",
      "verification": {
        "kind": "field",
        "value": 2712847316,
        "shift": 12,
        "mask": 255
      }
    },
    {
      "id": "M12-V03",
      "group": "M12",
      "sourceQuestion": 12,
      "sourcePage": 3,
      "variant": 3,
      "origin": "variant",
      "type": "mcq",
      "question": "Given unsigned int x = 0x0F1E2D3Cu, what is the value of (x >> 20) & 0xFFu?",
      "options": [
        "0xF0",
        "0x0F",
        "0x1E",
        "0xF1"
      ],
      "correct": 3,
      "explanation": "After shifting by 20 bits the value is 0xF1. Masking with 0xFF retains the selected low field, giving 0xF1.",
      "verification": {
        "kind": "field",
        "value": 253635900,
        "shift": 20,
        "mask": 255
      }
    },
    {
      "id": "M12-V04",
      "group": "M12",
      "sourceQuestion": 12,
      "sourcePage": 3,
      "variant": 4,
      "origin": "variant",
      "type": "mcq",
      "question": "Given unsigned int x = 0x76543210u, what is the value of (x >> 8) & 0xFFu?",
      "options": [
        "0x43",
        "0x32",
        "0x33",
        "0x21"
      ],
      "correct": 1,
      "explanation": "After shifting by 8 bits the value is 0x765432. Masking with 0xFF retains the selected low field, giving 0x32.",
      "verification": {
        "kind": "field",
        "value": 1985229328,
        "shift": 8,
        "mask": 255
      }
    },
    {
      "id": "M12-V05",
      "group": "M12",
      "sourceQuestion": 12,
      "sourcePage": 3,
      "variant": 5,
      "origin": "variant",
      "type": "mcq",
      "question": "Given unsigned int x = 0xABCD0123u, what is the value of (x >> 16) & 0xFFu?",
      "options": [
        "0xD0",
        "0xCC",
        "0xCD",
        "0xBC"
      ],
      "correct": 2,
      "explanation": "After shifting by 16 bits the value is 0xABCD. Masking with 0xFF retains the selected low field, giving 0xCD.",
      "verification": {
        "kind": "field",
        "value": 2882339107,
        "shift": 16,
        "mask": 255
      }
    },
    {
      "id": "M12-V06",
      "group": "M12",
      "sourceQuestion": 12,
      "sourcePage": 3,
      "variant": 6,
      "origin": "variant",
      "type": "mcq",
      "question": "Given unsigned int x = 0x13579BDFu, what is the value of (x >> 6) & 0x3Fu?",
      "options": [
        "0x37",
        "0x2E",
        "0x26",
        "0x2F"
      ],
      "correct": 3,
      "explanation": "After shifting by 6 bits the value is 0x4D5E6F. Masking with 0x3F retains the selected low field, giving 0x2F.",
      "verification": {
        "kind": "field",
        "value": 324508639,
        "shift": 6,
        "mask": 63
      }
    },
    {
      "id": "M12-V07",
      "group": "M12",
      "sourceQuestion": 12,
      "sourcePage": 3,
      "variant": 7,
      "origin": "variant",
      "type": "mcq",
      "question": "Given unsigned int x = 0xFEDCBA98u, what is the value of (x >> 10) & 0xFFu?",
      "options": [
        "0x2E",
        "0x72",
        "0xEA",
        "0x2F"
      ],
      "correct": 0,
      "explanation": "After shifting by 10 bits the value is 0x3FB72E. Masking with 0xFF retains the selected low field, giving 0x2E.",
      "verification": {
        "kind": "field",
        "value": 4275878552,
        "shift": 10,
        "mask": 255
      }
    },
    {
      "id": "M12-V08",
      "group": "M12",
      "sourceQuestion": 12,
      "sourcePage": 3,
      "variant": 8,
      "origin": "variant",
      "type": "mcq",
      "question": "Given unsigned int x = 0x80000F00u, what is the value of (x >> 4) & 0xFFu?",
      "options": [
        "0xF1",
        "0xF0",
        "0x00",
        "0x0F"
      ],
      "correct": 1,
      "explanation": "After shifting by 4 bits the value is 0x80000F0. Masking with 0xFF retains the selected low field, giving 0xF0.",
      "verification": {
        "kind": "field",
        "value": 2147487488,
        "shift": 4,
        "mask": 255
      }
    },
    {
      "id": "M12-V09",
      "group": "M12",
      "sourceQuestion": 12,
      "sourcePage": 3,
      "variant": 9,
      "origin": "variant",
      "type": "mcq",
      "question": "Given unsigned int x = 0x01020304u, what is the value of (x >> 0) & 0xFFu?",
      "options": [
        "0x05",
        "0x04",
        "0x14",
        "0x30"
      ],
      "correct": 1,
      "explanation": "After shifting by 0 bits the value is 0x1020304. Masking with 0xFF retains the selected low field, giving 0x04.",
      "verification": {
        "kind": "field",
        "value": 16909060,
        "shift": 0,
        "mask": 255
      }
    },
    {
      "id": "M12-V10",
      "group": "M12",
      "sourceQuestion": 12,
      "sourcePage": 3,
      "variant": 10,
      "origin": "variant",
      "type": "mcq",
      "question": "Given unsigned int x = 0xF2345678u, what is the value of (x >> 24) & 0xFFu?",
      "options": [
        "0xF3",
        "0x0F",
        "0xF2",
        "0x23"
      ],
      "correct": 2,
      "explanation": "After shifting by 24 bits the value is 0xF2. Masking with 0xFF retains the selected low field, giving 0xF2.",
      "verification": {
        "kind": "field",
        "value": 4063516280,
        "shift": 24,
        "mask": 255
      }
    },
    {
      "id": "M13-O",
      "group": "M13",
      "sourceQuestion": 13,
      "sourcePage": 3,
      "variant": 0,
      "origin": "original",
      "type": "mcq",
      "question": "The decimal value of the bit-string 0xF3E treated as a twos-complement value is:",
      "options": [
        "-194",
        "3902",
        "-3902",
        "-174"
      ],
      "correct": 0,
      "explanation": "Using exactly 12 bits, the unsigned value is 3902 and the sign bit is set. Subtract 4096 to obtain -194. If the width were 16 with a leading zero nibble, the value would instead be positive 3902.",
      "note": "Interpret the three hexadecimal digits as exactly 12 bits; the PDF does not explicitly state the width.",
      "verification": {
        "kind": "signed",
        "value": 3902,
        "width": 12
      }
    },
    {
      "id": "M13-V01",
      "group": "M13",
      "sourceQuestion": 13,
      "sourcePage": 3,
      "variant": 1,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the signed decimal value of the exactly 8-bit two’s-complement pattern 0xE7?",
      "options": [
        "-231",
        "-25",
        "-9",
        "231"
      ],
      "correct": 1,
      "explanation": "The unsigned value is 231. The highest bit is 1, so subtract 2^8 = 256: 231 - 256 = -25.",
      "verification": {
        "kind": "signed",
        "value": 231,
        "width": 8
      }
    },
    {
      "id": "M13-V02",
      "group": "M13",
      "sourceQuestion": 13,
      "sourcePage": 3,
      "variant": 2,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the signed decimal value of the exactly 8-bit two’s-complement pattern 0x80?",
      "options": [
        "-112",
        "-128",
        "128",
        "-144"
      ],
      "correct": 1,
      "explanation": "The unsigned value is 128. The highest bit is 1, so subtract 2^8 = 256: 128 - 256 = -128.",
      "verification": {
        "kind": "signed",
        "value": 128,
        "width": 8
      }
    },
    {
      "id": "M13-V03",
      "group": "M13",
      "sourceQuestion": 13,
      "sourcePage": 3,
      "variant": 3,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the signed decimal value of the exactly 8-bit two’s-complement pattern 0xFF?",
      "options": [
        "-255",
        "255",
        "15",
        "-1"
      ],
      "correct": 3,
      "explanation": "The unsigned value is 255. The highest bit is 1, so subtract 2^8 = 256: 255 - 256 = -1.",
      "verification": {
        "kind": "signed",
        "value": 255,
        "width": 8
      }
    },
    {
      "id": "M13-V04",
      "group": "M13",
      "sourceQuestion": 13,
      "sourcePage": 3,
      "variant": 4,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the signed decimal value of the exactly 12-bit two’s-complement pattern 0xF80?",
      "options": [
        "-112",
        "3968",
        "-3968",
        "-128"
      ],
      "correct": 3,
      "explanation": "The unsigned value is 3968. The highest bit is 1, so subtract 2^12 = 4096: 3968 - 4096 = -128.",
      "verification": {
        "kind": "signed",
        "value": 3968,
        "width": 12
      }
    },
    {
      "id": "M13-V05",
      "group": "M13",
      "sourceQuestion": 13,
      "sourcePage": 3,
      "variant": 5,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the signed decimal value of the exactly 12-bit two’s-complement pattern 0x800?",
      "options": [
        "-2048",
        "-2064",
        "2048",
        "-2032"
      ],
      "correct": 0,
      "explanation": "The unsigned value is 2048. The highest bit is 1, so subtract 2^12 = 4096: 2048 - 4096 = -2048.",
      "verification": {
        "kind": "signed",
        "value": 2048,
        "width": 12
      }
    },
    {
      "id": "M13-V06",
      "group": "M13",
      "sourceQuestion": 13,
      "sourcePage": 3,
      "variant": 6,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the signed decimal value of the exactly 12-bit two’s-complement pattern 0xFF0?",
      "options": [
        "4080",
        "-4080",
        "-16",
        "0"
      ],
      "correct": 2,
      "explanation": "The unsigned value is 4080. The highest bit is 1, so subtract 2^12 = 4096: 4080 - 4096 = -16.",
      "verification": {
        "kind": "signed",
        "value": 4080,
        "width": 12
      }
    },
    {
      "id": "M13-V07",
      "group": "M13",
      "sourceQuestion": 13,
      "sourcePage": 3,
      "variant": 7,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the signed decimal value of the exactly 16-bit two’s-complement pattern 0xFF3C?",
      "options": [
        "-65340",
        "-180",
        "-196",
        "65340"
      ],
      "correct": 2,
      "explanation": "The unsigned value is 65340. The highest bit is 1, so subtract 2^16 = 65536: 65340 - 65536 = -196.",
      "verification": {
        "kind": "signed",
        "value": 65340,
        "width": 16
      }
    },
    {
      "id": "M13-V08",
      "group": "M13",
      "sourceQuestion": 13,
      "sourcePage": 3,
      "variant": 8,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the signed decimal value of the exactly 16-bit two’s-complement pattern 0x8001?",
      "options": [
        "-32767",
        "-32751",
        "32769",
        "-32769"
      ],
      "correct": 0,
      "explanation": "The unsigned value is 32769. The highest bit is 1, so subtract 2^16 = 65536: 32769 - 65536 = -32767.",
      "verification": {
        "kind": "signed",
        "value": 32769,
        "width": 16
      }
    },
    {
      "id": "M13-V09",
      "group": "M13",
      "sourceQuestion": 13,
      "sourcePage": 3,
      "variant": 9,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the signed decimal value of the exactly 16-bit two’s-complement pattern 0xFED4?",
      "options": [
        "-65236",
        "65236",
        "-300",
        "-284"
      ],
      "correct": 2,
      "explanation": "The unsigned value is 65236. The highest bit is 1, so subtract 2^16 = 65536: 65236 - 65536 = -300.",
      "verification": {
        "kind": "signed",
        "value": 65236,
        "width": 16
      }
    },
    {
      "id": "M13-V10",
      "group": "M13",
      "sourceQuestion": 13,
      "sourcePage": 3,
      "variant": 10,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the signed decimal value of the exactly 12-bit two’s-complement pattern 0x7FE?",
      "options": [
        "-2046",
        "2062",
        "2046",
        "2030"
      ],
      "correct": 2,
      "explanation": "The unsigned value is 2046. The highest bit is 0, so the signed value remains 2046.",
      "verification": {
        "kind": "signed",
        "value": 2046,
        "width": 12
      }
    },
    {
      "id": "M14-O",
      "group": "M14",
      "sourceQuestion": 14,
      "sourcePage": 3,
      "variant": 0,
      "origin": "original",
      "type": "mcq",
      "question": "Which value of (signed) char x makes the following expression true? (Assume 8-bit arithmetic): x == -x?",
      "options": [
        "-128",
        "-142",
        "128",
        "127"
      ],
      "correct": 0,
      "explanation": "In the PDF’s wrapping eight-bit model, negating pattern 10000000 produces the same pattern, so -128 is the listed answer. Zero is also self-negating but is not listed. In actual C on a 32-bit-int machine, signed char promotes to int; -(-128) is 128, so none of these listed representable values satisfies the expression.",
      "note": "Use the explicitly requested toy model: negation wraps within eight bits before comparison. This is not ordinary C17 signed-char expression evaluation.",
      "verification": {
        "kind": "negation",
        "model": "wrap",
        "width": 8
      }
    },
    {
      "id": "M14-V01",
      "group": "M14",
      "sourceQuestion": 14,
      "sourcePage": 3,
      "variant": 1,
      "origin": "variant",
      "type": "mcq",
      "question": "In wrapping 8-bit two’s-complement arithmetic, which nonzero x satisfies x == -x?",
      "options": [
        "-1",
        "127",
        "-128",
        "-127"
      ],
      "correct": 2,
      "explanation": "Within 8 bits, zero and the minimum signed value -128 have self-negating patterns. The selected value is the only one of those allowed by the question and choices.",
      "verification": {
        "kind": "negation",
        "model": "wrap",
        "width": 8
      }
    },
    {
      "id": "M14-V02",
      "group": "M14",
      "sourceQuestion": 14,
      "sourcePage": 3,
      "variant": 2,
      "origin": "variant",
      "type": "mcq",
      "question": "In wrapping 8-bit two’s-complement arithmetic, which listed x satisfies x == -x?",
      "options": [
        "-1",
        "126",
        "0",
        "1"
      ],
      "correct": 2,
      "explanation": "Within 8 bits, zero and the minimum signed value -128 have self-negating patterns. The selected value is the only one of those allowed by the question and choices.",
      "verification": {
        "kind": "negation",
        "model": "wrap",
        "width": 8
      }
    },
    {
      "id": "M14-V03",
      "group": "M14",
      "sourceQuestion": 14,
      "sourcePage": 3,
      "variant": 3,
      "origin": "variant",
      "type": "mcq",
      "question": "In wrapping 4-bit two’s-complement arithmetic, which nonzero x satisfies x == -x?",
      "options": [
        "-8",
        "-1",
        "7",
        "-7"
      ],
      "correct": 0,
      "explanation": "Within 4 bits, zero and the minimum signed value -8 have self-negating patterns. The selected value is the only one of those allowed by the question and choices.",
      "verification": {
        "kind": "negation",
        "model": "wrap",
        "width": 4
      }
    },
    {
      "id": "M14-V04",
      "group": "M14",
      "sourceQuestion": 14,
      "sourcePage": 3,
      "variant": 4,
      "origin": "variant",
      "type": "mcq",
      "question": "In wrapping 16-bit two’s-complement arithmetic, which nonzero x satisfies x == -x?",
      "options": [
        "-1",
        "-32767",
        "32767",
        "-32768"
      ],
      "correct": 3,
      "explanation": "Within 16 bits, zero and the minimum signed value -32768 have self-negating patterns. The selected value is the only one of those allowed by the question and choices.",
      "verification": {
        "kind": "negation",
        "model": "wrap",
        "width": 16
      }
    },
    {
      "id": "M14-V05",
      "group": "M14",
      "sourceQuestion": 14,
      "sourcePage": 3,
      "variant": 5,
      "origin": "variant",
      "type": "mcq",
      "question": "Under actual C17 evaluation with 32-bit int and 8-bit signed char x, which value makes x == -x true?",
      "options": [
        "127",
        "-128",
        "-1",
        "0"
      ],
      "correct": 3,
      "explanation": "The char value promotes to int before negation. All possible char values have representable int negations on this machine; equality requires zero.",
      "verification": {
        "kind": "negation",
        "model": "promoted",
        "width": 8
      }
    },
    {
      "id": "M14-V06",
      "group": "M14",
      "sourceQuestion": 14,
      "sourcePage": 3,
      "variant": 6,
      "origin": "variant",
      "type": "mcq",
      "question": "Under actual C17 evaluation, unsigned char x promotes to 32-bit int. Which listed x makes x == -x true?",
      "options": [
        "128",
        "0",
        "1",
        "255"
      ],
      "correct": 1,
      "explanation": "The char value promotes to int before negation. All possible char values have representable int negations on this machine; equality requires zero.",
      "verification": {
        "kind": "negation",
        "model": "promoted",
        "width": 8
      }
    },
    {
      "id": "M14-V07",
      "group": "M14",
      "sourceQuestion": 14,
      "sourcePage": 3,
      "variant": 7,
      "origin": "variant",
      "type": "mcq",
      "question": "For 32-bit unsigned int x, which nonzero value makes x == -x true?",
      "options": [
        "2147483648",
        "2147483647",
        "1",
        "4294967295"
      ],
      "correct": 0,
      "explanation": "Unsigned negation is modulo 2^32. The nonzero halfway value 2^31 maps to itself: 2^32 - 2^31 = 2^31.",
      "verification": {
        "kind": "negation",
        "model": "wrapUnsigned",
        "width": 32
      }
    },
    {
      "id": "M14-V08",
      "group": "M14",
      "sourceQuestion": 14,
      "sourcePage": 3,
      "variant": 8,
      "origin": "variant",
      "type": "mcq",
      "question": "Under actual C17 evaluation with 32-bit int, signed char x is -128. What is the value of the expression -x?",
      "options": [
        "-128",
        "128",
        "127",
        "0"
      ],
      "correct": 1,
      "explanation": "The value -128 promotes to int before unary minus. The result 128 is representable as int, so no eight-bit truncation occurs in this expression.",
      "verification": {
        "kind": "negation",
        "model": "unary",
        "width": 8
      }
    },
    {
      "id": "M14-V09",
      "group": "M14",
      "sourceQuestion": 14,
      "sourcePage": 3,
      "variant": 9,
      "origin": "variant",
      "type": "mcq",
      "question": "A stored 8-bit pattern is 0x81. Negate it using wrapping two’s-complement arithmetic. What signed decimal value does the result represent?",
      "options": [
        "-127",
        "-128",
        "1",
        "127"
      ],
      "correct": 3,
      "explanation": "0x81 is -127 in eight-bit two’s complement. Inverting and adding one yields 0x7F, which is +127.",
      "verification": {
        "kind": "negation",
        "model": "negatePattern",
        "width": 8
      }
    },
    {
      "id": "M14-V10",
      "group": "M14",
      "sourceQuestion": 14,
      "sourcePage": 3,
      "variant": 10,
      "origin": "variant",
      "type": "mcq",
      "question": "In wrapping 8-bit two’s-complement arithmetic, which pair gives ALL values satisfying x == -x?",
      "options": [
        "-128 and 127",
        "0 and 127",
        "-1 and 1",
        "0 and -128"
      ],
      "correct": 3,
      "explanation": "Self-negation modulo 256 requires 2x to be a multiple of 256. The two stored patterns are 0x00 and 0x80, interpreted as 0 and -128.",
      "verification": {
        "kind": "negation",
        "model": "pair",
        "width": 8
      }
    },
    {
      "id": "M15-O",
      "group": "M15",
      "sourceQuestion": 15,
      "sourcePage": 3,
      "variant": 0,
      "origin": "original",
      "type": "mcq",
      "question": "Find a value of (signed) char x that makes the following expression true (Assume 8-bit arithmetic): x > 192U",
      "options": [
        "-10",
        "10",
        "127",
        "-147"
      ],
      "correct": 0,
      "explanation": "The representable negative candidate is -10. In the PDF’s unsigned eight-bit model it converts to 246, which exceeds 192. In actual C with 32-bit unsigned int, promotions/conversions yield 4294967286, also greater than 192U. -147 is outside the assumed signed-char range.",
      "note": "Use an eight-bit signed-char range of -128 through 127. The explanation distinguishes the PDF’s eight-bit model from actual C promotion.",
      "verification": {
        "kind": "comparison",
        "relation": ">",
        "threshold": 192,
        "unsigned": true,
        "signedChar": true
      }
    },
    {
      "id": "M15-V01",
      "group": "M15",
      "sourceQuestion": 15,
      "sourcePage": 3,
      "variant": 1,
      "origin": "variant",
      "type": "mcq",
      "question": "On a C17 machine with 32-bit int and unsigned int, which listed value of signed char x makes x > 200U true?",
      "options": [
        "-1",
        "0",
        "127",
        "100"
      ],
      "correct": 0,
      "explanation": "The unsigned int constant causes x to be compared as unsigned int. The selected -1 becomes 4294967295; compare that with 200. Negative candidates wrap modulo 2^32 during conversion.",
      "verification": {
        "kind": "comparison",
        "relation": ">",
        "threshold": 200,
        "unsigned": true,
        "signedChar": true
      }
    },
    {
      "id": "M15-V02",
      "group": "M15",
      "sourceQuestion": 15,
      "sourcePage": 3,
      "variant": 2,
      "origin": "variant",
      "type": "mcq",
      "question": "On a C17 machine with 32-bit int and unsigned int, which listed value of signed char x makes x > 100U true?",
      "options": [
        "100",
        "50",
        "0",
        "101"
      ],
      "correct": 3,
      "explanation": "The unsigned int constant causes x to be compared as unsigned int. The selected 101 becomes 101; compare that with 100. Negative candidates wrap modulo 2^32 during conversion.",
      "verification": {
        "kind": "comparison",
        "relation": ">",
        "threshold": 100,
        "unsigned": true,
        "signedChar": true
      }
    },
    {
      "id": "M15-V03",
      "group": "M15",
      "sourceQuestion": 15,
      "sourcePage": 3,
      "variant": 3,
      "origin": "variant",
      "type": "mcq",
      "question": "On a C17 machine with 32-bit int and unsigned int, which listed value of signed char x makes x < 10U true?",
      "options": [
        "-1",
        "0",
        "10",
        "127"
      ],
      "correct": 1,
      "explanation": "The unsigned int constant causes x to be compared as unsigned int. The selected 0 becomes 0; compare that with 10. Negative candidates wrap modulo 2^32 during conversion.",
      "verification": {
        "kind": "comparison",
        "relation": "<",
        "threshold": 10,
        "unsigned": true,
        "signedChar": true
      }
    },
    {
      "id": "M15-V04",
      "group": "M15",
      "sourceQuestion": 15,
      "sourcePage": 3,
      "variant": 4,
      "origin": "variant",
      "type": "mcq",
      "question": "On a C17 machine with 32-bit int and unsigned int, which listed value of signed char x makes x >= 127U true?",
      "options": [
        "0",
        "125",
        "126",
        "127"
      ],
      "correct": 3,
      "explanation": "The unsigned int constant causes x to be compared as unsigned int. The selected 127 becomes 127; compare that with 127. Negative candidates wrap modulo 2^32 during conversion.",
      "verification": {
        "kind": "comparison",
        "relation": ">=",
        "threshold": 127,
        "unsigned": true,
        "signedChar": true
      }
    },
    {
      "id": "M15-V05",
      "group": "M15",
      "sourceQuestion": 15,
      "sourcePage": 3,
      "variant": 5,
      "origin": "variant",
      "type": "mcq",
      "question": "On a C17 machine with 32-bit int and unsigned int, which listed value of int x makes x < 200 true?",
      "options": [
        "300",
        "200",
        "-10",
        "250"
      ],
      "correct": 2,
      "explanation": "The comparison is signed. -10 < 200 is true; adding or removing U can change the interpretation of negative operands.",
      "verification": {
        "kind": "comparison",
        "relation": "<",
        "threshold": 200,
        "unsigned": false,
        "signedChar": false
      }
    },
    {
      "id": "M15-V06",
      "group": "M15",
      "sourceQuestion": 15,
      "sourcePage": 3,
      "variant": 6,
      "origin": "variant",
      "type": "mcq",
      "question": "On a C17 machine with 32-bit int and unsigned int, which listed value of int x makes x > 192 true?",
      "options": [
        "193",
        "-10",
        "10",
        "127"
      ],
      "correct": 0,
      "explanation": "The comparison is signed. 193 > 192 is true; adding or removing U can change the interpretation of negative operands.",
      "verification": {
        "kind": "comparison",
        "relation": ">",
        "threshold": 192,
        "unsigned": false,
        "signedChar": false
      }
    },
    {
      "id": "M15-V07",
      "group": "M15",
      "sourceQuestion": 15,
      "sourcePage": 3,
      "variant": 7,
      "origin": "variant",
      "type": "mcq",
      "question": "On a C17 machine with 32-bit int and unsigned int, which listed value of signed char x makes x == 4294967295U true?",
      "options": [
        "1",
        "127",
        "0",
        "-1"
      ],
      "correct": 3,
      "explanation": "The unsigned int constant causes x to be compared as unsigned int. The selected -1 becomes 4294967295; compare that with 4294967295. Negative candidates wrap modulo 2^32 during conversion.",
      "verification": {
        "kind": "comparison",
        "relation": "==",
        "threshold": 4294967295,
        "unsigned": true,
        "signedChar": true
      }
    },
    {
      "id": "M15-V08",
      "group": "M15",
      "sourceQuestion": 15,
      "sourcePage": 3,
      "variant": 8,
      "origin": "variant",
      "type": "mcq",
      "question": "On a C17 machine with 32-bit int and unsigned int, which listed value of signed char x makes x > 4294967294U true?",
      "options": [
        "-1",
        "0",
        "127",
        "-2"
      ],
      "correct": 0,
      "explanation": "The unsigned int constant causes x to be compared as unsigned int. The selected -1 becomes 4294967295; compare that with 4294967294. Negative candidates wrap modulo 2^32 during conversion.",
      "verification": {
        "kind": "comparison",
        "relation": ">",
        "threshold": 4294967294,
        "unsigned": true,
        "signedChar": true
      }
    },
    {
      "id": "M15-V09",
      "group": "M15",
      "sourceQuestion": 15,
      "sourcePage": 3,
      "variant": 9,
      "origin": "variant",
      "type": "mcq",
      "question": "On a C17 machine with 32-bit int and unsigned int, which listed value of signed char x makes x < 1U true?",
      "options": [
        "1",
        "0",
        "127",
        "-128"
      ],
      "correct": 1,
      "explanation": "The unsigned int constant causes x to be compared as unsigned int. The selected 0 becomes 0; compare that with 1. Negative candidates wrap modulo 2^32 during conversion.",
      "verification": {
        "kind": "comparison",
        "relation": "<",
        "threshold": 1,
        "unsigned": true,
        "signedChar": true
      }
    },
    {
      "id": "M15-V10",
      "group": "M15",
      "sourceQuestion": 15,
      "sourcePage": 3,
      "variant": 10,
      "origin": "variant",
      "type": "mcq",
      "question": "On a C17 machine with 32-bit int and unsigned int, which listed value of signed char x makes x <= 0U true?",
      "options": [
        "0",
        "127",
        "-1",
        "1"
      ],
      "correct": 0,
      "explanation": "The unsigned int constant causes x to be compared as unsigned int. The selected 0 becomes 0; compare that with 0. Negative candidates wrap modulo 2^32 during conversion.",
      "verification": {
        "kind": "comparison",
        "relation": "<=",
        "threshold": 0,
        "unsigned": true,
        "signedChar": true
      }
    },
    {
      "id": "M16-O",
      "group": "M16",
      "sourceQuestion": 16,
      "sourcePage": 4,
      "variant": 0,
      "origin": "original",
      "type": "mcq",
      "question": "What is printed from the following piece of code:",
      "options": [
        "0",
        "128",
        "-128",
        "384"
      ],
      "correct": 2,
      "explanation": "Under the stated machine assumptions, narrowing 384 keeps low byte 0x80, interpreted as -128 by signed char. Widening to int preserves -128. If plain char were unsigned, the result would be 128. Out-of-range signed conversion is implementation-defined in C17.",
      "code": "int a = 384;\nchar b = a;\na = b;\nprintf(\"%d\\n\", a);",
      "note": "Assume eight-bit plain char is signed and out-of-range conversion preserves the low eight bits using two’s-complement interpretation.",
      "verification": {
        "kind": "narrow",
        "value": 384,
        "signed": true
      }
    },
    {
      "id": "M16-V01",
      "group": "M16",
      "sourceQuestion": 16,
      "sourcePage": 4,
      "variant": 1,
      "origin": "variant",
      "type": "mcq",
      "question": "What is printed by this sequence of conversions?",
      "options": [
        "0",
        "-2",
        "-1",
        "255"
      ],
      "correct": 2,
      "explanation": "The low eight bits of 255 form 0xFF. As signed char, that represents -1. Converting back to int preserves this value.",
      "code": "int a = 255;\nsigned char b = a;\na = b;\nprintf(\"%d\", a);",
      "note": "Assume an eight-bit two’s-complement signed char and an implementation that preserves the low eight bits on out-of-range conversion.",
      "verification": {
        "kind": "narrow",
        "value": 255,
        "signed": true
      }
    },
    {
      "id": "M16-V02",
      "group": "M16",
      "sourceQuestion": 16,
      "sourcePage": 4,
      "variant": 2,
      "origin": "variant",
      "type": "mcq",
      "question": "What is printed by this sequence of conversions?",
      "options": [
        "254",
        "255",
        "256",
        "-1"
      ],
      "correct": 1,
      "explanation": "The low eight bits of 255 form 0xFF. As unsigned char, that represents 255. Converting back to int preserves this value.",
      "code": "int a = 255;\nunsigned char b = a;\na = b;\nprintf(\"%d\", a);",
      "note": "Assume eight-bit unsigned char and 32-bit int.",
      "verification": {
        "kind": "narrow",
        "value": 255,
        "signed": false
      }
    },
    {
      "id": "M16-V03",
      "group": "M16",
      "sourceQuestion": 16,
      "sourcePage": 4,
      "variant": 3,
      "origin": "variant",
      "type": "mcq",
      "question": "What is printed by this sequence of conversions?",
      "options": [
        "1",
        "0",
        "256",
        "-1"
      ],
      "correct": 1,
      "explanation": "The low eight bits of 256 form 0x00. As signed char, that represents 0. Converting back to int preserves this value.",
      "code": "int a = 256;\nsigned char b = a;\na = b;\nprintf(\"%d\", a);",
      "note": "Assume an eight-bit two’s-complement signed char and an implementation that preserves the low eight bits on out-of-range conversion.",
      "verification": {
        "kind": "narrow",
        "value": 256,
        "signed": true
      }
    },
    {
      "id": "M16-V04",
      "group": "M16",
      "sourceQuestion": 16,
      "sourcePage": 4,
      "variant": 4,
      "origin": "variant",
      "type": "mcq",
      "question": "What is printed by this sequence of conversions?",
      "options": [
        "126",
        "383",
        "128",
        "127"
      ],
      "correct": 3,
      "explanation": "The low eight bits of 383 form 0x7F. As signed char, that represents 127. Converting back to int preserves this value.",
      "code": "int a = 383;\nsigned char b = a;\na = b;\nprintf(\"%d\", a);",
      "note": "Assume an eight-bit two’s-complement signed char and an implementation that preserves the low eight bits on out-of-range conversion.",
      "verification": {
        "kind": "narrow",
        "value": 383,
        "signed": true
      }
    },
    {
      "id": "M16-V05",
      "group": "M16",
      "sourceQuestion": 16,
      "sourcePage": 4,
      "variant": 5,
      "origin": "variant",
      "type": "mcq",
      "question": "What is printed by this sequence of conversions?",
      "options": [
        "255",
        "511",
        "-1",
        "256"
      ],
      "correct": 0,
      "explanation": "The low eight bits of 511 form 0xFF. As unsigned char, that represents 255. Converting back to int preserves this value.",
      "code": "int a = 511;\nunsigned char b = a;\na = b;\nprintf(\"%d\", a);",
      "note": "Assume eight-bit unsigned char and 32-bit int.",
      "verification": {
        "kind": "narrow",
        "value": 511,
        "signed": false
      }
    },
    {
      "id": "M16-V06",
      "group": "M16",
      "sourceQuestion": 16,
      "sourcePage": 4,
      "variant": 6,
      "origin": "variant",
      "type": "mcq",
      "question": "What is printed by this sequence of conversions?",
      "options": [
        "128",
        "-129",
        "-128",
        "-127"
      ],
      "correct": 2,
      "explanation": "The low eight bits of 128 form 0x80. As signed char, that represents -128. Converting back to int preserves this value.",
      "code": "int a = 128;\nsigned char b = a;\na = b;\nprintf(\"%d\", a);",
      "note": "Assume an eight-bit two’s-complement signed char and an implementation that preserves the low eight bits on out-of-range conversion.",
      "verification": {
        "kind": "narrow",
        "value": 128,
        "signed": true
      }
    },
    {
      "id": "M16-V07",
      "group": "M16",
      "sourceQuestion": 16,
      "sourcePage": 4,
      "variant": 7,
      "origin": "variant",
      "type": "mcq",
      "question": "What is printed by this sequence of conversions?",
      "options": [
        "256",
        "-1",
        "255",
        "254"
      ],
      "correct": 2,
      "explanation": "The low eight bits of -1 form 0xFF. As unsigned char, that represents 255. Converting back to int preserves this value.",
      "code": "int a = -1;\nunsigned char b = a;\na = b;\nprintf(\"%d\", a);",
      "note": "Assume eight-bit unsigned char and 32-bit int.",
      "verification": {
        "kind": "narrow",
        "value": -1,
        "signed": false
      }
    },
    {
      "id": "M16-V08",
      "group": "M16",
      "sourceQuestion": 16,
      "sourcePage": 4,
      "variant": 8,
      "origin": "variant",
      "type": "mcq",
      "question": "What is printed by this sequence of conversions?",
      "options": [
        "126",
        "128",
        "-129",
        "127"
      ],
      "correct": 3,
      "explanation": "The low eight bits of -129 form 0x7F. As signed char, that represents 127. Converting back to int preserves this value.",
      "code": "int a = -129;\nsigned char b = a;\na = b;\nprintf(\"%d\", a);",
      "note": "Assume an eight-bit two’s-complement signed char and an implementation that preserves the low eight bits on out-of-range conversion.",
      "verification": {
        "kind": "narrow",
        "value": -129,
        "signed": true
      }
    },
    {
      "id": "M16-V09",
      "group": "M16",
      "sourceQuestion": 16,
      "sourcePage": 4,
      "variant": 9,
      "origin": "variant",
      "type": "mcq",
      "question": "What is printed by this sequence of conversions?",
      "options": [
        "1",
        "2",
        "0",
        "1025"
      ],
      "correct": 0,
      "explanation": "The low eight bits of 1025 form 0x01. As unsigned char, that represents 1. Converting back to int preserves this value.",
      "code": "int a = 1025;\nunsigned char b = a;\na = b;\nprintf(\"%d\", a);",
      "note": "Assume eight-bit unsigned char and 32-bit int.",
      "verification": {
        "kind": "narrow",
        "value": 1025,
        "signed": false
      }
    },
    {
      "id": "M16-V10",
      "group": "M16",
      "sourceQuestion": 16,
      "sourcePage": 4,
      "variant": 10,
      "origin": "variant",
      "type": "mcq",
      "question": "What is printed by this sequence of conversions?",
      "options": [
        "-256",
        "0",
        "-1",
        "1"
      ],
      "correct": 1,
      "explanation": "The low eight bits of -256 form 0x00. As signed char, that represents 0. Converting back to int preserves this value.",
      "code": "int a = -256;\nsigned char b = a;\na = b;\nprintf(\"%d\", a);",
      "note": "Assume an eight-bit two’s-complement signed char and an implementation that preserves the low eight bits on out-of-range conversion.",
      "verification": {
        "kind": "narrow",
        "value": -256,
        "signed": true
      }
    },
    {
      "id": "M17-O",
      "group": "M17",
      "sourceQuestion": 17,
      "sourcePage": 4,
      "variant": 0,
      "origin": "original",
      "type": "mcq",
      "question": "What is the value of the mask if i = 11?",
      "options": [
        "0x08",
        "0x20",
        "0xf7",
        "0xff"
      ],
      "correct": 0,
      "explanation": "The byte index is 11 >> 3 = 1. The local bit index is 11 & 7 = 3, so the mask is 1 << 3 = 8 = 0x08. The byte index is not the shift count.",
      "code": "void set(char *bits, int i) {\n    int idx = i >> 3;\n    int bidx = i & 7;\n    char mask = 1 << bidx;\n    bits[idx] = bits[idx] | mask;\n}",
      "verification": {
        "kind": "packed",
        "index": 11,
        "ask": "mask"
      }
    },
    {
      "id": "M17-V01",
      "group": "M17",
      "sourceQuestion": 17,
      "sourcePage": 4,
      "variant": 1,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the value of mask when i = 0?",
      "options": [
        "0x02",
        "0x00",
        "0x01",
        "0xFE"
      ],
      "correct": 2,
      "explanation": "i / 8 = 0 identifies the byte. i % 8 = 0 identifies the local bit, so 1u << 0 gives 0x01. Bit 0 is the least significant bit within each byte.",
      "code": "void set(unsigned char *bits, unsigned int i) {\n    unsigned int idx = i >> 3;\n    unsigned int bidx = i & 7u;\n    unsigned char mask = (unsigned char)(1u << bidx);\n    bits[idx] = (unsigned char)(bits[idx] | mask);\n}",
      "verification": {
        "kind": "packed",
        "index": 0,
        "ask": "mask"
      }
    },
    {
      "id": "M17-V02",
      "group": "M17",
      "sourceQuestion": 17,
      "sourcePage": 4,
      "variant": 2,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the value of mask when i = 7?",
      "options": [
        "0x7F",
        "0x01",
        "0x80",
        "0x00"
      ],
      "correct": 2,
      "explanation": "i / 8 = 0 identifies the byte. i % 8 = 7 identifies the local bit, so 1u << 7 gives 0x80. Bit 0 is the least significant bit within each byte.",
      "code": "void set(unsigned char *bits, unsigned int i) {\n    unsigned int idx = i >> 3;\n    unsigned int bidx = i & 7u;\n    unsigned char mask = (unsigned char)(1u << bidx);\n    bits[idx] = (unsigned char)(bits[idx] | mask);\n}",
      "verification": {
        "kind": "packed",
        "index": 7,
        "ask": "mask"
      }
    },
    {
      "id": "M17-V03",
      "group": "M17",
      "sourceQuestion": 17,
      "sourcePage": 4,
      "variant": 3,
      "origin": "variant",
      "type": "mcq",
      "question": "For i = 8, what are idx and mask, in that order?",
      "options": [
        "2, 0x01",
        "1, 0x02",
        "1, 0x01",
        "0, 0x01"
      ],
      "correct": 2,
      "explanation": "i / 8 = 1 identifies the byte. i % 8 = 0 identifies the local bit, so 1u << 0 gives 0x01. Bit 0 is the least significant bit within each byte.",
      "code": "void set(unsigned char *bits, unsigned int i) {\n    unsigned int idx = i >> 3;\n    unsigned int bidx = i & 7u;\n    unsigned char mask = (unsigned char)(1u << bidx);\n    bits[idx] = (unsigned char)(bits[idx] | mask);\n}",
      "verification": {
        "kind": "packed",
        "index": 8,
        "ask": "both"
      }
    },
    {
      "id": "M17-V04",
      "group": "M17",
      "sourceQuestion": 17,
      "sourcePage": 4,
      "variant": 4,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the value of mask when i = 15?",
      "options": [
        "0xFF",
        "0x80",
        "0x01",
        "0x7F"
      ],
      "correct": 1,
      "explanation": "i / 8 = 1 identifies the byte. i % 8 = 7 identifies the local bit, so 1u << 7 gives 0x80. Bit 0 is the least significant bit within each byte.",
      "code": "void set(unsigned char *bits, unsigned int i) {\n    unsigned int idx = i >> 3;\n    unsigned int bidx = i & 7u;\n    unsigned char mask = (unsigned char)(1u << bidx);\n    bits[idx] = (unsigned char)(bits[idx] | mask);\n}",
      "verification": {
        "kind": "packed",
        "index": 15,
        "ask": "mask"
      }
    },
    {
      "id": "M17-V05",
      "group": "M17",
      "sourceQuestion": 17,
      "sourcePage": 4,
      "variant": 5,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the value of mask when i = 16?",
      "options": [
        "0x01",
        "0xFE",
        "0x02",
        "0xFF"
      ],
      "correct": 0,
      "explanation": "i / 8 = 2 identifies the byte. i % 8 = 0 identifies the local bit, so 1u << 0 gives 0x01. Bit 0 is the least significant bit within each byte.",
      "code": "void set(unsigned char *bits, unsigned int i) {\n    unsigned int idx = i >> 3;\n    unsigned int bidx = i & 7u;\n    unsigned char mask = (unsigned char)(1u << bidx);\n    bits[idx] = (unsigned char)(bits[idx] | mask);\n}",
      "verification": {
        "kind": "packed",
        "index": 16,
        "ask": "mask"
      }
    },
    {
      "id": "M17-V06",
      "group": "M17",
      "sourceQuestion": 17,
      "sourcePage": 4,
      "variant": 6,
      "origin": "variant",
      "type": "mcq",
      "question": "For i = 23, what are idx and mask, in that order?",
      "options": [
        "2, 0x01",
        "3, 0x80",
        "2, 0x80",
        "7, 0x80"
      ],
      "correct": 2,
      "explanation": "i / 8 = 2 identifies the byte. i % 8 = 7 identifies the local bit, so 1u << 7 gives 0x80. Bit 0 is the least significant bit within each byte.",
      "code": "void set(unsigned char *bits, unsigned int i) {\n    unsigned int idx = i >> 3;\n    unsigned int bidx = i & 7u;\n    unsigned char mask = (unsigned char)(1u << bidx);\n    bits[idx] = (unsigned char)(bits[idx] | mask);\n}",
      "verification": {
        "kind": "packed",
        "index": 23,
        "ask": "both"
      }
    },
    {
      "id": "M17-V07",
      "group": "M17",
      "sourceQuestion": 17,
      "sourcePage": 4,
      "variant": 7,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the value of mask when i = 31?",
      "options": [
        "0x7F",
        "0x03",
        "0x80",
        "0x01"
      ],
      "correct": 2,
      "explanation": "i / 8 = 3 identifies the byte. i % 8 = 7 identifies the local bit, so 1u << 7 gives 0x80. Bit 0 is the least significant bit within each byte.",
      "code": "void set(unsigned char *bits, unsigned int i) {\n    unsigned int idx = i >> 3;\n    unsigned int bidx = i & 7u;\n    unsigned char mask = (unsigned char)(1u << bidx);\n    bits[idx] = (unsigned char)(bits[idx] | mask);\n}",
      "verification": {
        "kind": "packed",
        "index": 31,
        "ask": "mask"
      }
    },
    {
      "id": "M17-V08",
      "group": "M17",
      "sourceQuestion": 17,
      "sourcePage": 4,
      "variant": 8,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the value of mask when i = 32?",
      "options": [
        "0xFE",
        "0x04",
        "0x01",
        "0x02"
      ],
      "correct": 2,
      "explanation": "i / 8 = 4 identifies the byte. i % 8 = 0 identifies the local bit, so 1u << 0 gives 0x01. Bit 0 is the least significant bit within each byte.",
      "code": "void set(unsigned char *bits, unsigned int i) {\n    unsigned int idx = i >> 3;\n    unsigned int bidx = i & 7u;\n    unsigned char mask = (unsigned char)(1u << bidx);\n    bits[idx] = (unsigned char)(bits[idx] | mask);\n}",
      "verification": {
        "kind": "packed",
        "index": 32,
        "ask": "mask"
      }
    },
    {
      "id": "M17-V09",
      "group": "M17",
      "sourceQuestion": 17,
      "sourcePage": 4,
      "variant": 9,
      "origin": "variant",
      "type": "mcq",
      "question": "For i = 41, what are idx and mask, in that order?",
      "options": [
        "6, 0x02",
        "5, 0x04",
        "5, 0x02",
        "1, 0x02"
      ],
      "correct": 2,
      "explanation": "i / 8 = 5 identifies the byte. i % 8 = 1 identifies the local bit, so 1u << 1 gives 0x02. Bit 0 is the least significant bit within each byte.",
      "code": "void set(unsigned char *bits, unsigned int i) {\n    unsigned int idx = i >> 3;\n    unsigned int bidx = i & 7u;\n    unsigned char mask = (unsigned char)(1u << bidx);\n    bits[idx] = (unsigned char)(bits[idx] | mask);\n}",
      "verification": {
        "kind": "packed",
        "index": 41,
        "ask": "both"
      }
    },
    {
      "id": "M17-V10",
      "group": "M17",
      "sourceQuestion": 17,
      "sourcePage": 4,
      "variant": 10,
      "origin": "variant",
      "type": "mcq",
      "question": "What is the value of mask when i = 63?",
      "options": [
        "0x80",
        "0x07",
        "0x7F",
        "0x01"
      ],
      "correct": 0,
      "explanation": "i / 8 = 7 identifies the byte. i % 8 = 7 identifies the local bit, so 1u << 7 gives 0x80. Bit 0 is the least significant bit within each byte.",
      "code": "void set(unsigned char *bits, unsigned int i) {\n    unsigned int idx = i >> 3;\n    unsigned int bidx = i & 7u;\n    unsigned char mask = (unsigned char)(1u << bidx);\n    bits[idx] = (unsigned char)(bits[idx] | mask);\n}",
      "verification": {
        "kind": "packed",
        "index": 63,
        "ask": "mask"
      }
    },
    {
      "id": "M18-O",
      "group": "M18",
      "sourceQuestion": 18,
      "sourcePage": 4,
      "variant": 0,
      "origin": "original",
      "type": "mcq",
      "question": "Which function name best describes this code?",
      "options": [
        "is_node_allocated()",
        "is_node_head()",
        "is_node_tail()",
        "is_node_in_list()"
      ],
      "correct": 3,
      "explanation": "The loop compares node with every reachable node address and returns 1 on any match. It returns 0 after exhausting the chain; it does not allocate or free anything.",
      "code": "int mystery(linked_list_t *list, ll_node_t *node) {\n    for (ll_node_t *ptr = list->head; ptr != NULL; ptr = ptr->next) {\n        if (node == ptr) return 1;\n    }\n    return 0;\n}",
      "note": "Assume list is a valid pointer, the chain is finite and acyclic, its length fits in int, and each node has int value and a next pointer. Nodes are compared by address unless the code compares value.",
      "verification": {
        "kind": "list",
        "contract": "contains"
      }
    },
    {
      "id": "M18-V01",
      "group": "M18",
      "sourceQuestion": 18,
      "sourcePage": 4,
      "variant": 1,
      "origin": "variant",
      "type": "mcq",
      "question": "Which function name best describes the behavior of this code?",
      "options": [
        "is_node_head()",
        "is_node_tail()",
        "is_node_in_list()",
        "is_list_empty()"
      ],
      "correct": 0,
      "explanation": "Only the head pointer is compared. A matching node elsewhere in the list is not accepted.",
      "code": "int mystery(linked_list_t *list, ll_node_t *node) {\n    return node != NULL && list->head == node;\n}",
      "note": "Assume list is a valid pointer, the chain is finite and acyclic, its length fits in int, and each node has int value and a next pointer. Nodes are compared by address unless the code compares value.",
      "verification": {
        "kind": "list",
        "contract": "head"
      }
    },
    {
      "id": "M18-V02",
      "group": "M18",
      "sourceQuestion": 18,
      "sourcePage": 4,
      "variant": 2,
      "origin": "variant",
      "type": "mcq",
      "question": "Which function name best describes the behavior of this code?",
      "options": [
        "is_node_head()",
        "is_node_tail()",
        "is_node_in_list()",
        "is_list_empty()"
      ],
      "correct": 1,
      "explanation": "The comparison is performed only at the final node, whose next pointer is NULL. An empty list returns 0.",
      "code": "int mystery(linked_list_t *list, ll_node_t *node) {\n    for (ll_node_t *p = list->head; p != NULL; p = p->next) {\n        if (p->next == NULL) return p == node;\n    }\n    return 0;\n}",
      "note": "Assume list is a valid pointer, the chain is finite and acyclic, its length fits in int, and each node has int value and a next pointer. Nodes are compared by address unless the code compares value.",
      "verification": {
        "kind": "list",
        "contract": "tail"
      }
    },
    {
      "id": "M18-V03",
      "group": "M18",
      "sourceQuestion": 18,
      "sourcePage": 4,
      "variant": 3,
      "origin": "variant",
      "type": "mcq",
      "question": "Which function name best describes the behavior of this code?",
      "options": [
        "contains_zero_value()",
        "is_list_empty()",
        "has_one_node()",
        "list_length()"
      ],
      "correct": 1,
      "explanation": "A NULL head means no nodes are reachable. The function returns a Boolean, not a node count.",
      "code": "int mystery(linked_list_t *list) {\n    return list->head == NULL;\n}",
      "note": "Assume list is a valid pointer, the chain is finite and acyclic, its length fits in int, and each node has int value and a next pointer. Nodes are compared by address unless the code compares value.",
      "verification": {
        "kind": "list",
        "contract": "empty"
      }
    },
    {
      "id": "M18-V04",
      "group": "M18",
      "sourceQuestion": 18,
      "sourcePage": 4,
      "variant": 4,
      "origin": "variant",
      "type": "mcq",
      "question": "Which function name best describes the behavior of this code?",
      "options": [
        "sum_node_values()",
        "index_of_tail()",
        "is_list_empty()",
        "list_length()"
      ],
      "correct": 3,
      "explanation": "The counter advances once per node, regardless of stored value. Empty lists return 0.",
      "code": "int mystery(linked_list_t *list) {\n    int n = 0;\n    for (ll_node_t *p = list->head; p != NULL; p = p->next) ++n;\n    return n;\n}",
      "note": "Assume list is a valid pointer, the chain is finite and acyclic, its length fits in int, and each node has int value and a next pointer. Nodes are compared by address unless the code compares value.",
      "verification": {
        "kind": "list",
        "contract": "length"
      }
    },
    {
      "id": "M18-V05",
      "group": "M18",
      "sourceQuestion": 18,
      "sourcePage": 4,
      "variant": 5,
      "origin": "variant",
      "type": "mcq",
      "question": "Which function name best describes the behavior of this code?",
      "options": [
        "contains_node_address()",
        "contains_value()",
        "count_value_matches()",
        "sum_node_values()"
      ],
      "correct": 1,
      "explanation": "It compares each stored int with target and returns on the first match. Equal values in different nodes are sufficient.",
      "code": "int mystery(linked_list_t *list, int target) {\n    for (ll_node_t *p = list->head; p != NULL; p = p->next) {\n        if (p->value == target) return 1;\n    }\n    return 0;\n}",
      "note": "Assume list is a valid pointer, the chain is finite and acyclic, its length fits in int, and each node has int value and a next pointer. Nodes are compared by address unless the code compares value.",
      "verification": {
        "kind": "list",
        "contract": "value"
      }
    },
    {
      "id": "M18-V06",
      "group": "M18",
      "sourceQuestion": 18,
      "sourcePage": 4,
      "variant": 6,
      "origin": "variant",
      "type": "mcq",
      "question": "Which function name best describes the behavior of this code?",
      "options": [
        "list_length()",
        "index_of_tail()",
        "index_of_node()",
        "is_node_in_list()"
      ],
      "correct": 2,
      "explanation": "The returned counter is the zero-based index of the matching node. -1 means the address was not found.",
      "code": "int mystery(linked_list_t *list, ll_node_t *node) {\n    int i = 0;\n    for (ll_node_t *p = list->head; p != NULL; p = p->next, ++i) {\n        if (p == node) return i;\n    }\n    return -1;\n}",
      "note": "Assume list is a valid pointer, the chain is finite and acyclic, its length fits in int, and each node has int value and a next pointer. Nodes are compared by address unless the code compares value.",
      "verification": {
        "kind": "list",
        "contract": "index"
      }
    },
    {
      "id": "M18-V07",
      "group": "M18",
      "sourceQuestion": 18,
      "sourcePage": 4,
      "variant": 7,
      "origin": "variant",
      "type": "mcq",
      "question": "Which function name best describes the behavior of this code?",
      "options": [
        "has_predecessor_in_list()",
        "has_successor_in_list()",
        "is_node_head()",
        "is_node_tail()"
      ],
      "correct": 0,
      "explanation": "The comparison looks at each next link. It succeeds when some listed node links directly to the supplied non-NULL node.",
      "code": "int mystery(linked_list_t *list, ll_node_t *node) {\n    if (node == NULL) return 0;\n    for (ll_node_t *p = list->head; p != NULL; p = p->next) {\n        if (p->next == node) return 1;\n    }\n    return 0;\n}",
      "note": "Assume list is a valid pointer, the chain is finite and acyclic, its length fits in int, and each node has int value and a next pointer. Nodes are compared by address unless the code compares value.",
      "verification": {
        "kind": "list",
        "contract": "predecessor"
      }
    },
    {
      "id": "M18-V08",
      "group": "M18",
      "sourceQuestion": 18,
      "sourcePage": 4,
      "variant": 8,
      "origin": "variant",
      "type": "mcq",
      "question": "Which function name best describes the behavior of this code?",
      "options": [
        "all_values_equal()",
        "has_at_least_two_nodes()",
        "has_exactly_one_node()",
        "is_list_empty()"
      ],
      "correct": 2,
      "explanation": "The first condition requires a head; the second requires it to have no successor. Short-circuiting prevents a NULL dereference.",
      "code": "int mystery(linked_list_t *list) {\n    return list->head != NULL && list->head->next == NULL;\n}",
      "note": "Assume list is a valid pointer, the chain is finite and acyclic, its length fits in int, and each node has int value and a next pointer. Nodes are compared by address unless the code compares value.",
      "verification": {
        "kind": "list",
        "contract": "singleton"
      }
    },
    {
      "id": "M18-V09",
      "group": "M18",
      "sourceQuestion": 18,
      "sourcePage": 4,
      "variant": 9,
      "origin": "variant",
      "type": "mcq",
      "question": "Which function name best describes the behavior of this code?",
      "options": [
        "index_of_first_match()",
        "sum_node_values()",
        "count_value_matches()",
        "contains_value()"
      ],
      "correct": 2,
      "explanation": "Every matching node increments count, so duplicate values contribute separately. The scan does not stop after its first match.",
      "code": "int mystery(linked_list_t *list, int target) {\n    int count = 0;\n    for (ll_node_t *p = list->head; p != NULL; p = p->next) {\n        if (p->value == target) ++count;\n    }\n    return count;\n}",
      "note": "Assume list is a valid pointer, the chain is finite and acyclic, its length fits in int, and each node has int value and a next pointer. Nodes are compared by address unless the code compares value.",
      "verification": {
        "kind": "list",
        "contract": "count"
      }
    },
    {
      "id": "M18-V10",
      "group": "M18",
      "sourceQuestion": 18,
      "sourcePage": 4,
      "variant": 10,
      "origin": "variant",
      "type": "mcq",
      "question": "Which function name best describes the behavior of this code?",
      "options": [
        "is_node_tail()",
        "is_node_in_list()",
        "is_node_head()",
        "is_node_after_head()"
      ],
      "correct": 3,
      "explanation": "The first reachable node is deliberately skipped. The function accepts any matching node from the second position onward, not only the tail.",
      "code": "int mystery(linked_list_t *list, ll_node_t *node) {\n    ll_node_t *p = list->head;\n    if (p != NULL) p = p->next;\n    for (; p != NULL; p = p->next) {\n        if (p == node) return 1;\n    }\n    return 0;\n}",
      "note": "Assume list is a valid pointer, the chain is finite and acyclic, its length fits in int, and each node has int value and a next pointer. Nodes are compared by address unless the code compares value.",
      "verification": {
        "kind": "list",
        "contract": "afterHead"
      }
    },
    {
      "id": "M19-O",
      "group": "M19",
      "sourceQuestion": 19,
      "sourcePage": 5,
      "variant": 0,
      "origin": "original",
      "type": "trace",
      "question": "The variable values after line 3 executes are shown below. (a) What are they after line 4 is executed? (b) After line 5 is executed?",
      "code": "1  int main(void) {\n2      int A[] = {50, 60, 70, 80, 90};\n3      int *Aptr = A;\n4      Aptr = Aptr + 3;\n5      *Aptr = *Aptr + 3;\n6      return 0;\n7  }",
      "note": "Assume sizeof(int) = 4 bytes. Addresses in the diagram are illustrative, increasing from left to right. For each part, give the full array and the pointer’s stored address or target index.",
      "initialMemory": {
        "values": [
          50,
          60,
          70,
          80,
          90
        ],
        "pointerIndex": 0,
        "baseAddress": 256,
        "pointerStorageAddress": 516,
        "elementBytes": 4,
        "pointerName": "Aptr"
      },
      "parts": [
        {
          "label": "After line 4",
          "answer": "A = {50, 60, 70, 80, 90}; Aptr holds 0x10C and points to A[3].",
          "values": [
            50,
            60,
            70,
            80,
            90
          ],
          "pointerIndex": 3,
          "pointerAddress": 268
        },
        {
          "label": "After line 5",
          "answer": "A = {50, 60, 70, 83, 90}; Aptr holds 0x10C and points to A[3].",
          "values": [
            50,
            60,
            70,
            83,
            90
          ],
          "pointerIndex": 3,
          "pointerAddress": 268
        }
      ],
      "rubric": [
        "Track the pointer destination and full array after line 4.",
        "Track the pointer destination and full array after line 5."
      ],
      "explanation": "Pointer arithmetic advances by array elements, while dereferencing accesses an element’s value. The pointer variable has its own storage address; that address is distinct from the array address stored in it.",
      "verification": {
        "kind": "trace",
        "values": [
          50,
          60,
          70,
          80,
          90
        ],
        "start": 0,
        "steps": [
          "Aptr = Aptr + 3;",
          "*Aptr = *Aptr + 3;"
        ],
        "pointerName": "Aptr"
      }
    },
    {
      "id": "M19-V01",
      "group": "M19",
      "sourceQuestion": 19,
      "sourcePage": 5,
      "variant": 1,
      "origin": "variant",
      "type": "trace",
      "question": "The variable values after line 3 executes are shown below. (a) What are they after line 4 is executed? (b) After line 5 is executed?",
      "code": "1  int main(void) {\n2      int A[] = {10, 20, 30, 40, 50};\n3      int *p = A;\n4      p = p + 2;\n5      *p = *p - 5;\n6      return 0;\n7  }",
      "note": "Assume sizeof(int) = 4 bytes. Addresses in the diagram are illustrative, increasing from left to right. For each part, give the full array and the pointer’s stored address or target index.",
      "initialMemory": {
        "values": [
          10,
          20,
          30,
          40,
          50
        ],
        "pointerIndex": 0,
        "baseAddress": 768,
        "pointerStorageAddress": 896,
        "elementBytes": 4,
        "pointerName": "p"
      },
      "parts": [
        {
          "label": "After line 4",
          "answer": "A = {10, 20, 30, 40, 50}; p holds 0x308 and points to A[2].",
          "values": [
            10,
            20,
            30,
            40,
            50
          ],
          "pointerIndex": 2,
          "pointerAddress": 776
        },
        {
          "label": "After line 5",
          "answer": "A = {10, 20, 25, 40, 50}; p holds 0x308 and points to A[2].",
          "values": [
            10,
            20,
            25,
            40,
            50
          ],
          "pointerIndex": 2,
          "pointerAddress": 776
        }
      ],
      "rubric": [
        "Track the pointer destination and full array after line 4.",
        "Track the pointer destination and full array after line 5."
      ],
      "explanation": "Pointer arithmetic advances by array elements, while dereferencing accesses an element’s value. The pointer variable has its own storage address; that address is distinct from the array address stored in it.",
      "verification": {
        "kind": "trace",
        "values": [
          10,
          20,
          30,
          40,
          50
        ],
        "start": 0,
        "steps": [
          "p = p + 2;",
          "*p = *p - 5;"
        ],
        "pointerName": "p"
      }
    },
    {
      "id": "M19-V02",
      "group": "M19",
      "sourceQuestion": 19,
      "sourcePage": 5,
      "variant": 2,
      "origin": "variant",
      "type": "trace",
      "question": "The variable values after line 3 executes are shown below. (a) What are they after line 4 is executed? (b) After line 5 is executed?",
      "code": "1  int main(void) {\n2      int A[] = {3, 6, 9, 12, 15};\n3      int *p = A + 1;\n4      p = &A[4];\n5      *p += A[0];\n6      return 0;\n7  }",
      "note": "Assume sizeof(int) = 4 bytes. Addresses in the diagram are illustrative, increasing from left to right. For each part, give the full array and the pointer’s stored address or target index.",
      "initialMemory": {
        "values": [
          3,
          6,
          9,
          12,
          15
        ],
        "pointerIndex": 1,
        "baseAddress": 1024,
        "pointerStorageAddress": 1152,
        "elementBytes": 4,
        "pointerName": "p"
      },
      "parts": [
        {
          "label": "After line 4",
          "answer": "A = {3, 6, 9, 12, 15}; p holds 0x410 and points to A[4].",
          "values": [
            3,
            6,
            9,
            12,
            15
          ],
          "pointerIndex": 4,
          "pointerAddress": 1040
        },
        {
          "label": "After line 5",
          "answer": "A = {3, 6, 9, 12, 18}; p holds 0x410 and points to A[4].",
          "values": [
            3,
            6,
            9,
            12,
            18
          ],
          "pointerIndex": 4,
          "pointerAddress": 1040
        }
      ],
      "rubric": [
        "Track the pointer destination and full array after line 4.",
        "Track the pointer destination and full array after line 5."
      ],
      "explanation": "Pointer arithmetic advances by array elements, while dereferencing accesses an element’s value. The pointer variable has its own storage address; that address is distinct from the array address stored in it.",
      "verification": {
        "kind": "trace",
        "values": [
          3,
          6,
          9,
          12,
          15
        ],
        "start": 1,
        "steps": [
          "p = &A[4];",
          "*p += A[0];"
        ],
        "pointerName": "p"
      }
    },
    {
      "id": "M19-V03",
      "group": "M19",
      "sourceQuestion": 19,
      "sourcePage": 5,
      "variant": 3,
      "origin": "variant",
      "type": "trace",
      "question": "The variable values after line 3 executes are shown below. (a) What are they after line 4 is executed? (b) After line 5 is executed?",
      "code": "1  int main(void) {\n2      int A[] = {11, 22, 33, 44, 55};\n3      int *p = A + 3;\n4      p = p - 1;\n5      *(p + 1) = 9;\n6      return 0;\n7  }",
      "note": "Assume sizeof(int) = 4 bytes. Addresses in the diagram are illustrative, increasing from left to right. For each part, give the full array and the pointer’s stored address or target index.",
      "initialMemory": {
        "values": [
          11,
          22,
          33,
          44,
          55
        ],
        "pointerIndex": 3,
        "baseAddress": 1280,
        "pointerStorageAddress": 1408,
        "elementBytes": 4,
        "pointerName": "p"
      },
      "parts": [
        {
          "label": "After line 4",
          "answer": "A = {11, 22, 33, 44, 55}; p holds 0x508 and points to A[2].",
          "values": [
            11,
            22,
            33,
            44,
            55
          ],
          "pointerIndex": 2,
          "pointerAddress": 1288
        },
        {
          "label": "After line 5",
          "answer": "A = {11, 22, 33, 9, 55}; p holds 0x508 and points to A[2].",
          "values": [
            11,
            22,
            33,
            9,
            55
          ],
          "pointerIndex": 2,
          "pointerAddress": 1288
        }
      ],
      "rubric": [
        "Track the pointer destination and full array after line 4.",
        "Track the pointer destination and full array after line 5."
      ],
      "explanation": "Pointer arithmetic advances by array elements, while dereferencing accesses an element’s value. The pointer variable has its own storage address; that address is distinct from the array address stored in it.",
      "verification": {
        "kind": "trace",
        "values": [
          11,
          22,
          33,
          44,
          55
        ],
        "start": 3,
        "steps": [
          "p = p - 1;",
          "*(p + 1) = 9;"
        ],
        "pointerName": "p"
      }
    },
    {
      "id": "M19-V04",
      "group": "M19",
      "sourceQuestion": 19,
      "sourcePage": 5,
      "variant": 4,
      "origin": "variant",
      "type": "trace",
      "question": "The variable values after line 3 executes are shown below. (a) What are they after line 4 is executed? (b) After line 5 is executed?",
      "code": "1  int main(void) {\n2      int A[] = {2, 4, 6, 8, 10};\n3      int *p = A;\n4      p++;\n5      (*p)++;\n6      return 0;\n7  }",
      "note": "Assume sizeof(int) = 4 bytes. Addresses in the diagram are illustrative, increasing from left to right. For each part, give the full array and the pointer’s stored address or target index.",
      "initialMemory": {
        "values": [
          2,
          4,
          6,
          8,
          10
        ],
        "pointerIndex": 0,
        "baseAddress": 1536,
        "pointerStorageAddress": 1664,
        "elementBytes": 4,
        "pointerName": "p"
      },
      "parts": [
        {
          "label": "After line 4",
          "answer": "A = {2, 4, 6, 8, 10}; p holds 0x604 and points to A[1].",
          "values": [
            2,
            4,
            6,
            8,
            10
          ],
          "pointerIndex": 1,
          "pointerAddress": 1540
        },
        {
          "label": "After line 5",
          "answer": "A = {2, 5, 6, 8, 10}; p holds 0x604 and points to A[1].",
          "values": [
            2,
            5,
            6,
            8,
            10
          ],
          "pointerIndex": 1,
          "pointerAddress": 1540
        }
      ],
      "rubric": [
        "Track the pointer destination and full array after line 4.",
        "Track the pointer destination and full array after line 5."
      ],
      "explanation": "Pointer arithmetic advances by array elements, while dereferencing accesses an element’s value. The pointer variable has its own storage address; that address is distinct from the array address stored in it.",
      "verification": {
        "kind": "trace",
        "values": [
          2,
          4,
          6,
          8,
          10
        ],
        "start": 0,
        "steps": [
          "p++;",
          "(*p)++;"
        ],
        "pointerName": "p"
      }
    },
    {
      "id": "M19-V05",
      "group": "M19",
      "sourceQuestion": 19,
      "sourcePage": 5,
      "variant": 5,
      "origin": "variant",
      "type": "trace",
      "question": "The variable values after line 3 executes are shown below. (a) What are they after line 4 is executed? (b) After line 5 is executed?",
      "code": "1  int main(void) {\n2      int A[] = {5, 10, 15, 20, 25};\n3      int *p = A;\n4      p += 1;\n5      *p++ = 77;\n6      return 0;\n7  }",
      "note": "Assume sizeof(int) = 4 bytes. Addresses in the diagram are illustrative, increasing from left to right. For each part, give the full array and the pointer’s stored address or target index.",
      "initialMemory": {
        "values": [
          5,
          10,
          15,
          20,
          25
        ],
        "pointerIndex": 0,
        "baseAddress": 1792,
        "pointerStorageAddress": 1920,
        "elementBytes": 4,
        "pointerName": "p"
      },
      "parts": [
        {
          "label": "After line 4",
          "answer": "A = {5, 10, 15, 20, 25}; p holds 0x704 and points to A[1].",
          "values": [
            5,
            10,
            15,
            20,
            25
          ],
          "pointerIndex": 1,
          "pointerAddress": 1796
        },
        {
          "label": "After line 5",
          "answer": "A = {5, 77, 15, 20, 25}; p holds 0x708 and points to A[2].",
          "values": [
            5,
            77,
            15,
            20,
            25
          ],
          "pointerIndex": 2,
          "pointerAddress": 1800
        }
      ],
      "rubric": [
        "Track the pointer destination and full array after line 4.",
        "Track the pointer destination and full array after line 5."
      ],
      "explanation": "Pointer arithmetic advances by array elements, while dereferencing accesses an element’s value. The pointer variable has its own storage address; that address is distinct from the array address stored in it.",
      "verification": {
        "kind": "trace",
        "values": [
          5,
          10,
          15,
          20,
          25
        ],
        "start": 0,
        "steps": [
          "p += 1;",
          "*p++ = 77;"
        ],
        "pointerName": "p"
      }
    },
    {
      "id": "M19-V06",
      "group": "M19",
      "sourceQuestion": 19,
      "sourcePage": 5,
      "variant": 6,
      "origin": "variant",
      "type": "trace",
      "question": "The variable values after line 3 executes are shown below. (a) What are they after line 4 is executed? (b) After line 5 is executed?",
      "code": "1  int main(void) {\n2      int A[] = {1, 3, 5, 7, 9};\n3      int *p = A;\n4      p = &A[1];\n5      p[2] += 6;\n6      return 0;\n7  }",
      "note": "Assume sizeof(int) = 4 bytes. Addresses in the diagram are illustrative, increasing from left to right. For each part, give the full array and the pointer’s stored address or target index.",
      "initialMemory": {
        "values": [
          1,
          3,
          5,
          7,
          9
        ],
        "pointerIndex": 0,
        "baseAddress": 2048,
        "pointerStorageAddress": 2176,
        "elementBytes": 4,
        "pointerName": "p"
      },
      "parts": [
        {
          "label": "After line 4",
          "answer": "A = {1, 3, 5, 7, 9}; p holds 0x804 and points to A[1].",
          "values": [
            1,
            3,
            5,
            7,
            9
          ],
          "pointerIndex": 1,
          "pointerAddress": 2052
        },
        {
          "label": "After line 5",
          "answer": "A = {1, 3, 5, 13, 9}; p holds 0x804 and points to A[1].",
          "values": [
            1,
            3,
            5,
            13,
            9
          ],
          "pointerIndex": 1,
          "pointerAddress": 2052
        }
      ],
      "rubric": [
        "Track the pointer destination and full array after line 4.",
        "Track the pointer destination and full array after line 5."
      ],
      "explanation": "Pointer arithmetic advances by array elements, while dereferencing accesses an element’s value. The pointer variable has its own storage address; that address is distinct from the array address stored in it.",
      "verification": {
        "kind": "trace",
        "values": [
          1,
          3,
          5,
          7,
          9
        ],
        "start": 0,
        "steps": [
          "p = &A[1];",
          "p[2] += 6;"
        ],
        "pointerName": "p"
      }
    },
    {
      "id": "M19-V07",
      "group": "M19",
      "sourceQuestion": 19,
      "sourcePage": 5,
      "variant": 7,
      "origin": "variant",
      "type": "trace",
      "question": "The variable values after line 3 executes are shown below. (a) What are they after line 4 is executed? (b) After line 5 is executed?",
      "code": "1  int main(void) {\n2      int A[] = {8, 16, 24, 32, 40};\n3      int *p = A + 4;\n4      p -= 2;\n5      *p = *(p + 2);\n6      return 0;\n7  }",
      "note": "Assume sizeof(int) = 4 bytes. Addresses in the diagram are illustrative, increasing from left to right. For each part, give the full array and the pointer’s stored address or target index.",
      "initialMemory": {
        "values": [
          8,
          16,
          24,
          32,
          40
        ],
        "pointerIndex": 4,
        "baseAddress": 2304,
        "pointerStorageAddress": 2432,
        "elementBytes": 4,
        "pointerName": "p"
      },
      "parts": [
        {
          "label": "After line 4",
          "answer": "A = {8, 16, 24, 32, 40}; p holds 0x908 and points to A[2].",
          "values": [
            8,
            16,
            24,
            32,
            40
          ],
          "pointerIndex": 2,
          "pointerAddress": 2312
        },
        {
          "label": "After line 5",
          "answer": "A = {8, 16, 40, 32, 40}; p holds 0x908 and points to A[2].",
          "values": [
            8,
            16,
            40,
            32,
            40
          ],
          "pointerIndex": 2,
          "pointerAddress": 2312
        }
      ],
      "rubric": [
        "Track the pointer destination and full array after line 4.",
        "Track the pointer destination and full array after line 5."
      ],
      "explanation": "Pointer arithmetic advances by array elements, while dereferencing accesses an element’s value. The pointer variable has its own storage address; that address is distinct from the array address stored in it.",
      "verification": {
        "kind": "trace",
        "values": [
          8,
          16,
          24,
          32,
          40
        ],
        "start": 4,
        "steps": [
          "p -= 2;",
          "*p = *(p + 2);"
        ],
        "pointerName": "p"
      }
    },
    {
      "id": "M19-V08",
      "group": "M19",
      "sourceQuestion": 19,
      "sourcePage": 5,
      "variant": 8,
      "origin": "variant",
      "type": "trace",
      "question": "The variable values after line 3 executes are shown below. (a) What are they after line 4 is executed? (b) After line 5 is executed?",
      "code": "1  int main(void) {\n2      int A[] = {7, 14, 21, 28, 35};\n3      int *p = A + 2;\n4      p = A + 4;\n5      *(p - 3) = *p;\n6      return 0;\n7  }",
      "note": "Assume sizeof(int) = 4 bytes. Addresses in the diagram are illustrative, increasing from left to right. For each part, give the full array and the pointer’s stored address or target index.",
      "initialMemory": {
        "values": [
          7,
          14,
          21,
          28,
          35
        ],
        "pointerIndex": 2,
        "baseAddress": 2560,
        "pointerStorageAddress": 2688,
        "elementBytes": 4,
        "pointerName": "p"
      },
      "parts": [
        {
          "label": "After line 4",
          "answer": "A = {7, 14, 21, 28, 35}; p holds 0xA10 and points to A[4].",
          "values": [
            7,
            14,
            21,
            28,
            35
          ],
          "pointerIndex": 4,
          "pointerAddress": 2576
        },
        {
          "label": "After line 5",
          "answer": "A = {7, 35, 21, 28, 35}; p holds 0xA10 and points to A[4].",
          "values": [
            7,
            35,
            21,
            28,
            35
          ],
          "pointerIndex": 4,
          "pointerAddress": 2576
        }
      ],
      "rubric": [
        "Track the pointer destination and full array after line 4.",
        "Track the pointer destination and full array after line 5."
      ],
      "explanation": "Pointer arithmetic advances by array elements, while dereferencing accesses an element’s value. The pointer variable has its own storage address; that address is distinct from the array address stored in it.",
      "verification": {
        "kind": "trace",
        "values": [
          7,
          14,
          21,
          28,
          35
        ],
        "start": 2,
        "steps": [
          "p = A + 4;",
          "*(p - 3) = *p;"
        ],
        "pointerName": "p"
      }
    },
    {
      "id": "M19-V09",
      "group": "M19",
      "sourceQuestion": 19,
      "sourcePage": 5,
      "variant": 9,
      "origin": "variant",
      "type": "trace",
      "question": "The variable values after line 3 executes are shown below. (a) What are they after line 4 is executed? (b) After line 5 is executed?",
      "code": "1  int main(void) {\n2      int A[] = {0, -2, 4, -6, 8};\n3      int *p = A + 2;\n4      p += 0;\n5      *p += 0;\n6      return 0;\n7  }",
      "note": "Assume sizeof(int) = 4 bytes. Addresses in the diagram are illustrative, increasing from left to right. For each part, give the full array and the pointer’s stored address or target index.",
      "initialMemory": {
        "values": [
          0,
          -2,
          4,
          -6,
          8
        ],
        "pointerIndex": 2,
        "baseAddress": 2816,
        "pointerStorageAddress": 2944,
        "elementBytes": 4,
        "pointerName": "p"
      },
      "parts": [
        {
          "label": "After line 4",
          "answer": "A = {0, -2, 4, -6, 8}; p holds 0xB08 and points to A[2].",
          "values": [
            0,
            -2,
            4,
            -6,
            8
          ],
          "pointerIndex": 2,
          "pointerAddress": 2824
        },
        {
          "label": "After line 5",
          "answer": "A = {0, -2, 4, -6, 8}; p holds 0xB08 and points to A[2].",
          "values": [
            0,
            -2,
            4,
            -6,
            8
          ],
          "pointerIndex": 2,
          "pointerAddress": 2824
        }
      ],
      "rubric": [
        "Track the pointer destination and full array after line 4.",
        "Track the pointer destination and full array after line 5."
      ],
      "explanation": "Pointer arithmetic advances by array elements, while dereferencing accesses an element’s value. The pointer variable has its own storage address; that address is distinct from the array address stored in it.",
      "verification": {
        "kind": "trace",
        "values": [
          0,
          -2,
          4,
          -6,
          8
        ],
        "start": 2,
        "steps": [
          "p += 0;",
          "*p += 0;"
        ],
        "pointerName": "p"
      }
    },
    {
      "id": "M19-V10",
      "group": "M19",
      "sourceQuestion": 19,
      "sourcePage": 5,
      "variant": 10,
      "origin": "variant",
      "type": "trace",
      "question": "The variable values after line 3 executes are shown below. (a) What are they after line 4 is executed? (b) After line 5 is executed?",
      "code": "1  int main(void) {\n2      int A[] = {9, 18, 27, 36, 45};\n3      int *p = A;\n4      p = A + 5;\n5      p--;\n6      return 0;\n7  }",
      "note": "Assume sizeof(int) = 4 bytes. Addresses in the diagram are illustrative, increasing from left to right. For each part, give the full array and the pointer’s stored address or target index.",
      "initialMemory": {
        "values": [
          9,
          18,
          27,
          36,
          45
        ],
        "pointerIndex": 0,
        "baseAddress": 3072,
        "pointerStorageAddress": 3200,
        "elementBytes": 4,
        "pointerName": "p"
      },
      "parts": [
        {
          "label": "After line 4",
          "answer": "A = {9, 18, 27, 36, 45}; p holds 0xC14 (one past the array; do not dereference it).",
          "values": [
            9,
            18,
            27,
            36,
            45
          ],
          "pointerIndex": 5,
          "pointerAddress": 3092
        },
        {
          "label": "After line 5",
          "answer": "A = {9, 18, 27, 36, 45}; p holds 0xC10 and points to A[4].",
          "values": [
            9,
            18,
            27,
            36,
            45
          ],
          "pointerIndex": 4,
          "pointerAddress": 3088
        }
      ],
      "rubric": [
        "Track the pointer destination and full array after line 4.",
        "Track the pointer destination and full array after line 5."
      ],
      "explanation": "Pointer arithmetic advances by array elements, while dereferencing accesses an element’s value. The pointer variable has its own storage address; that address is distinct from the array address stored in it.",
      "verification": {
        "kind": "trace",
        "values": [
          9,
          18,
          27,
          36,
          45
        ],
        "start": 0,
        "steps": [
          "p = A + 5;",
          "p--;"
        ],
        "pointerName": "p"
      }
    },
    {
      "id": "M20-O",
      "group": "M20",
      "sourceQuestion": 20,
      "sourcePage": 5,
      "variant": 0,
      "origin": "original",
      "type": "code",
      "question": "Recall that the function int strlen(char *string), which takes a pointer to a character array and returns the length of the string stored in it. Give the C code for this function. Note: It does not need to be perfect C code, but it does need to be recognizable as C code.",
      "code": "int strlen(char *string);",
      "modelAnswer": "int strlen(char *string) {\n    int length = 0;\n    while (string[length] != '\\0') {\n        ++length;\n    }\n    return length;\n}",
      "rubric": [
        "Initialize the count or start pointer correctly.",
        "Stop at the first null character or other limit required by the contract.",
        "Advance safely without skipping or double-counting characters.",
        "Return the required value, including for the empty case."
      ],
      "explanation": "Count characters preceding the first null byte. An empty string returns zero. This is a teaching implementation with the PDF’s simplified signature; the standard library uses size_t strlen(const char *).",
      "verification": {
        "kind": "implementation",
        "cases": [
          {
            "setup": "char s[] = \"\";",
            "call": "strlen(s)",
            "expected": 0
          },
          {
            "setup": "char s[] = \"HELLO\";",
            "call": "strlen(s)",
            "expected": 5
          },
          {
            "setup": "char s[] = {'A',0,'B',0};",
            "call": "strlen(s)",
            "expected": 1
          }
        ]
      },
      "note": "Use the PDF’s requested signature. Assume a valid null-terminated string whose length fits in int. No library strlen call may be used. The signature is simplified from the standard library declaration."
    },
    {
      "id": "M20-V01",
      "group": "M20",
      "sourceQuestion": 20,
      "sourcePage": 5,
      "variant": 1,
      "origin": "variant",
      "type": "code",
      "question": "Implement a function that returns the number of characters before the first null byte. Do not call a string library function. Give recognizable C code for the function.",
      "code": "int text_length(const char *s);",
      "modelAnswer": "int text_length(const char *s) {\n    int n = 0;\n    while (s[n] != '\\0') ++n;\n    return n;\n}",
      "rubric": [
        "Initialize the count or start pointer correctly.",
        "Stop at the first null character or other limit required by the contract.",
        "Advance safely without skipping or double-counting characters.",
        "Return the required value, including for the empty case."
      ],
      "explanation": "Follow the stated stopping condition and return contract. The reference implementation is one possible solution; other implementations are valid if they meet the same contract and boundary cases.",
      "verification": {
        "kind": "implementation",
        "cases": [
          {
            "setup": "const char s[] = \"\";",
            "call": "text_length(s)",
            "expected": 0
          },
          {
            "setup": "const char s[] = \"ABCD\";",
            "call": "text_length(s)",
            "expected": 4
          }
        ]
      },
      "note": "Assume valid readable storage for every byte the contract permits examining. Counts and pointer differences fit their return types; required standard declarations are available. Do not use library string-length functions."
    },
    {
      "id": "M20-V02",
      "group": "M20",
      "sourceQuestion": 20,
      "sourcePage": 5,
      "variant": 2,
      "origin": "variant",
      "type": "code",
      "question": "Implement the string-length function using a moving pointer rather than array subscripts. Do not call strlen. Give recognizable C code for the function.",
      "code": "size_t pointer_length(const char *s);",
      "modelAnswer": "size_t pointer_length(const char *s) {\n    const char *p = s;\n    while (*p != '\\0') ++p;\n    return (size_t)(p - s);\n}",
      "rubric": [
        "Initialize the count or start pointer correctly.",
        "Stop at the first null character or other limit required by the contract.",
        "Advance safely without skipping or double-counting characters.",
        "Return the required value, including for the empty case."
      ],
      "explanation": "Follow the stated stopping condition and return contract. The reference implementation is one possible solution; other implementations are valid if they meet the same contract and boundary cases.",
      "verification": {
        "kind": "implementation",
        "cases": [
          {
            "setup": "const char s[] = \"\";",
            "call": "pointer_length(s)",
            "expected": 0
          },
          {
            "setup": "const char s[] = \"A B\";",
            "call": "pointer_length(s)",
            "expected": 3
          }
        ]
      },
      "note": "Assume valid readable storage for every byte the contract permits examining. Counts and pointer differences fit their return types; required standard declarations are available. Do not use library string-length functions."
    },
    {
      "id": "M20-V03",
      "group": "M20",
      "sourceQuestion": 20,
      "sourcePage": 5,
      "variant": 3,
      "origin": "variant",
      "type": "code",
      "question": "Return the length of the suffix beginning at index start. start is between zero and the full string length, inclusive. Do not count the characters before start. Give recognizable C code for the function.",
      "code": "int suffix_length(const char *s, int start);",
      "modelAnswer": "int suffix_length(const char *s, int start) {\n    int n = 0;\n    while (s[start + n] != '\\0') ++n;\n    return n;\n}",
      "rubric": [
        "Initialize the count or start pointer correctly.",
        "Stop at the first null character or other limit required by the contract.",
        "Advance safely without skipping or double-counting characters.",
        "Return the required value, including for the empty case."
      ],
      "explanation": "Follow the stated stopping condition and return contract. The reference implementation is one possible solution; other implementations are valid if they meet the same contract and boundary cases.",
      "verification": {
        "kind": "implementation",
        "cases": [
          {
            "setup": "const char s[] = \"ABCDE\";",
            "call": "suffix_length(s, 2)",
            "expected": 3
          },
          {
            "setup": "const char s[] = \"ABCDE\";",
            "call": "suffix_length(s, 5)",
            "expected": 0
          },
          {
            "setup": "const char s[] = \"\";",
            "call": "suffix_length(s, 0)",
            "expected": 0
          }
        ]
      },
      "note": "Assume valid readable storage for every byte the contract permits examining. Counts and pointer differences fit their return types; required standard declarations are available. Do not use library string-length functions."
    },
    {
      "id": "M20-V04",
      "group": "M20",
      "sourceQuestion": 20,
      "sourcePage": 5,
      "variant": 4,
      "origin": "variant",
      "type": "code",
      "question": "Return the number of characters before the first null byte, but examine at most limit bytes. If no null occurs within that limit, return limit. If limit is zero, do not read s. Give recognizable C code for the function.",
      "code": "size_t bounded_length(const char *s, size_t limit);",
      "modelAnswer": "size_t bounded_length(const char *s, size_t limit) {\n    size_t n = 0;\n    while (n < limit && s[n] != '\\0') ++n;\n    return n;\n}",
      "rubric": [
        "Initialize the count or start pointer correctly.",
        "Stop at the first null character or other limit required by the contract.",
        "Advance safely without skipping or double-counting characters.",
        "Return the required value, including for the empty case."
      ],
      "explanation": "Follow the stated stopping condition and return contract. The reference implementation is one possible solution; other implementations are valid if they meet the same contract and boundary cases.",
      "verification": {
        "kind": "implementation",
        "cases": [
          {
            "setup": "char s[3] = {'A','B','C'};",
            "call": "bounded_length(s, 3)",
            "expected": 3
          },
          {
            "setup": "char s[] = \"A\";",
            "call": "bounded_length(s, 2)",
            "expected": 1
          },
          {
            "setup": "",
            "call": "bounded_length(NULL, 0)",
            "expected": 0
          }
        ]
      },
      "note": "Assume valid readable storage for every byte the contract permits examining. Counts and pointer differences fit their return types; required standard declarations are available. Do not use library string-length functions."
    },
    {
      "id": "M20-V05",
      "group": "M20",
      "sourceQuestion": 20,
      "sourcePage": 5,
      "variant": 5,
      "origin": "variant",
      "type": "code",
      "question": "Count occurrences of the non-null character target before the first null byte. A character after that terminator must not be counted. Give recognizable C code for the function.",
      "code": "int count_char(const char *s, char target);",
      "modelAnswer": "int count_char(const char *s, char target) {\n    int count = 0;\n    for (int i = 0; s[i] != '\\0'; ++i) {\n        if (s[i] == target) ++count;\n    }\n    return count;\n}",
      "rubric": [
        "Initialize the count or start pointer correctly.",
        "Stop at the first null character or other limit required by the contract.",
        "Advance safely without skipping or double-counting characters.",
        "Return the required value, including for the empty case."
      ],
      "explanation": "Follow the stated stopping condition and return contract. The reference implementation is one possible solution; other implementations are valid if they meet the same contract and boundary cases.",
      "verification": {
        "kind": "implementation",
        "cases": [
          {
            "setup": "char s[] = \"BANANA\";",
            "call": "count_char(s, 'A')",
            "expected": 3
          },
          {
            "setup": "char s[] = {'A',0,'A',0};",
            "call": "count_char(s, 'A')",
            "expected": 1
          },
          {
            "setup": "char s[] = \"\";",
            "call": "count_char(s, 'A')",
            "expected": 0
          }
        ]
      },
      "note": "Assume valid readable storage for every byte the contract permits examining. Counts and pointer differences fit their return types; required standard declarations are available. Do not use library string-length functions."
    },
    {
      "id": "M20-V06",
      "group": "M20",
      "sourceQuestion": 20,
      "sourcePage": 5,
      "variant": 6,
      "origin": "variant",
      "type": "code",
      "question": "Return the length of the prefix before the first occurrence of stop or the first null byte, whichever comes first. Exclude the stopping character. Give recognizable C code for the function.",
      "code": "int prefix_length(const char *s, char stop);",
      "modelAnswer": "int prefix_length(const char *s, char stop) {\n    int n = 0;\n    while (s[n] != '\\0' && s[n] != stop) ++n;\n    return n;\n}",
      "rubric": [
        "Initialize the count or start pointer correctly.",
        "Stop at the first null character or other limit required by the contract.",
        "Advance safely without skipping or double-counting characters.",
        "Return the required value, including for the empty case."
      ],
      "explanation": "Follow the stated stopping condition and return contract. The reference implementation is one possible solution; other implementations are valid if they meet the same contract and boundary cases.",
      "verification": {
        "kind": "implementation",
        "cases": [
          {
            "setup": "char s[] = \"ab:cd\";",
            "call": "prefix_length(s, ':')",
            "expected": 2
          },
          {
            "setup": "char s[] = \"abc\";",
            "call": "prefix_length(s, ':')",
            "expected": 3
          },
          {
            "setup": "char s[] = \":a\";",
            "call": "prefix_length(s, ':')",
            "expected": 0
          }
        ]
      },
      "note": "Assume valid readable storage for every byte the contract permits examining. Counts and pointer differences fit their return types; required standard declarations are available. Do not use library string-length functions."
    },
    {
      "id": "M20-V07",
      "group": "M20",
      "sourceQuestion": 20,
      "sourcePage": 5,
      "variant": 7,
      "origin": "variant",
      "type": "code",
      "question": "Return the index of the last non-null character in the string. Return -1 for an empty string. Do not use strlen. Give recognizable C code for the function.",
      "code": "int last_char_index(const char *s);",
      "modelAnswer": "int last_char_index(const char *s) {\n    int n = 0;\n    while (s[n] != '\\0') ++n;\n    return n - 1;\n}",
      "rubric": [
        "Initialize the count or start pointer correctly.",
        "Stop at the first null character or other limit required by the contract.",
        "Advance safely without skipping or double-counting characters.",
        "Return the required value, including for the empty case."
      ],
      "explanation": "Follow the stated stopping condition and return contract. The reference implementation is one possible solution; other implementations are valid if they meet the same contract and boundary cases.",
      "verification": {
        "kind": "implementation",
        "cases": [
          {
            "setup": "char s[] = \"\";",
            "call": "last_char_index(s)",
            "expected": -1
          },
          {
            "setup": "char s[] = \"A\";",
            "call": "last_char_index(s)",
            "expected": 0
          },
          {
            "setup": "char s[] = \"TEST\";",
            "call": "last_char_index(s)",
            "expected": 3
          }
        ]
      },
      "note": "Assume valid readable storage for every byte the contract permits examining. Counts and pointer differences fit their return types; required standard declarations are available. Do not use library string-length functions."
    },
    {
      "id": "M20-V08",
      "group": "M20",
      "sourceQuestion": 20,
      "sourcePage": 5,
      "variant": 8,
      "origin": "variant",
      "type": "code",
      "question": "Return 1 if the string contains at least n characters before its terminator, otherwise return 0. n is nonnegative. Stop scanning as soon as the answer is known. Give recognizable C code for the function.",
      "code": "int has_at_least(const char *s, int n);",
      "modelAnswer": "int has_at_least(const char *s, int n) {\n    int i = 0;\n    while (i < n) {\n        if (s[i] == '\\0') return 0;\n        ++i;\n    }\n    return 1;\n}",
      "rubric": [
        "Initialize the count or start pointer correctly.",
        "Stop at the first null character or other limit required by the contract.",
        "Advance safely without skipping or double-counting characters.",
        "Return the required value, including for the empty case."
      ],
      "explanation": "Follow the stated stopping condition and return contract. The reference implementation is one possible solution; other implementations are valid if they meet the same contract and boundary cases.",
      "verification": {
        "kind": "implementation",
        "cases": [
          {
            "setup": "char s[] = \"\";",
            "call": "has_at_least(s, 0)",
            "expected": 1
          },
          {
            "setup": "char s[] = \"abc\";",
            "call": "has_at_least(s, 3)",
            "expected": 1
          },
          {
            "setup": "char s[] = \"abc\";",
            "call": "has_at_least(s, 4)",
            "expected": 0
          }
        ]
      },
      "note": "Assume valid readable storage for every byte the contract permits examining. Counts and pointer differences fit their return types; required standard declarations are available. Do not use library string-length functions."
    },
    {
      "id": "M20-V09",
      "group": "M20",
      "sourceQuestion": 20,
      "sourcePage": 5,
      "variant": 9,
      "origin": "variant",
      "type": "code",
      "question": "Return -1 when s is NULL. Otherwise return the length of the null-terminated string. Do not use strlen. Give recognizable C code for the function.",
      "code": "int checked_length(const char *s);",
      "modelAnswer": "int checked_length(const char *s) {\n    if (s == NULL) return -1;\n    int n = 0;\n    while (s[n] != '\\0') ++n;\n    return n;\n}",
      "rubric": [
        "Initialize the count or start pointer correctly.",
        "Stop at the first null character or other limit required by the contract.",
        "Advance safely without skipping or double-counting characters.",
        "Return the required value, including for the empty case."
      ],
      "explanation": "Follow the stated stopping condition and return contract. The reference implementation is one possible solution; other implementations are valid if they meet the same contract and boundary cases.",
      "verification": {
        "kind": "implementation",
        "cases": [
          {
            "setup": "",
            "call": "checked_length(NULL)",
            "expected": -1
          },
          {
            "setup": "char s[] = \"\";",
            "call": "checked_length(s)",
            "expected": 0
          },
          {
            "setup": "char s[] = \"hello\";",
            "call": "checked_length(s)",
            "expected": 5
          }
        ]
      },
      "note": "Assume valid readable storage for every byte the contract permits examining. Counts and pointer differences fit their return types; required standard declarations are available. Do not use library string-length functions."
    },
    {
      "id": "M20-V10",
      "group": "M20",
      "sourceQuestion": 20,
      "sourcePage": 5,
      "variant": 10,
      "origin": "variant",
      "type": "code",
      "question": "Compute the length of each of count null-terminated strings and store it in the corresponding out element. Do not use strlen. count is nonnegative; both arrays have count elements. Give recognizable C code for the function.",
      "code": "void string_lengths(const char *const strings[], int count, int out[]);",
      "modelAnswer": "void string_lengths(const char *const strings[], int count, int out[]) {\n    for (int i = 0; i < count; ++i) {\n        int n = 0;\n        while (strings[i][n] != '\\0') ++n;\n        out[i] = n;\n    }\n}",
      "rubric": [
        "Initialize the count or start pointer correctly.",
        "Stop at the first null character or other limit required by the contract.",
        "Advance safely without skipping or double-counting characters.",
        "Return the required value, including for the empty case."
      ],
      "explanation": "Follow the stated stopping condition and return contract. The reference implementation is one possible solution; other implementations are valid if they meet the same contract and boundary cases.",
      "verification": {
        "kind": "implementation",
        "cases": [
          {
            "setup": "const char *s[] = {\"\", \"A\", \"BC\"}; int out[3] = {-1,-1,-1};",
            "invoke": "string_lengths(s, 3, out);",
            "assert": "out[0] == 0 && out[1] == 1 && out[2] == 2"
          },
          {
            "setup": "int out[1] = {99};",
            "invoke": "string_lengths(NULL, 0, out);",
            "assert": "out[0] == 99"
          }
        ]
      },
      "note": "Assume valid readable storage for every byte the contract permits examining. Counts and pointer differences fit their return types; required standard declarations are available. Do not use library string-length functions."
    },
    {
      "id": "M21-O",
      "group": "M21",
      "sourceQuestion": 21,
      "sourcePage": 5,
      "variant": 0,
      "origin": "original",
      "type": "code",
      "question": "Recall that the function void *memset(void *ptr, char byte, int size) takes a pointer to memory, a byte and the size of the memory and initializes each byte of the memory with the specified byte. Give the C code for the function. Note: it does not need to be perfect C code, but it does have to be recognizable as C code.",
      "code": "void *memset(void *ptr, char byte, int size);",
      "modelAnswer": "void *memset(void *ptr, char byte, int size) {\n    unsigned char *p = ptr;\n    for (int i = 0; i < size; ++i) {\n        p[i] = (unsigned char)byte;\n    }\n    return ptr;\n}",
      "rubric": [
        "Use a character pointer to address individual bytes.",
        "Honor the exact bounds and the zero-length case.",
        "Write the requested byte value without changing bytes outside the range.",
        "Return the required pointer or count; preserve the original pointer when needed."
      ],
      "explanation": "A character pointer makes each step one byte. The loop writes offsets 0 through size - 1 and returns the original address. The PDF uses a simplified signature; standard memset takes an int byte value and a size_t count.",
      "verification": {
        "kind": "implementation",
        "cases": [
          {
            "setup": "unsigned char b[] = {9,9,9,9};",
            "invoke": "void *r = memset(b+1, 3, 2);",
            "assert": "r == b+1 && b[0] == 9 && b[1] == 3 && b[2] == 3 && b[3] == 9"
          },
          {
            "setup": "unsigned char b[] = {9};",
            "invoke": "void *r = memset(b, 5, 0);",
            "assert": "r == b && b[0] == 9"
          }
        ]
      },
      "note": "Use the PDF’s simplified signature; size is nonnegative and ptr designates at least size writable bytes. Return the original pointer. Do not call a library memory-filling function."
    },
    {
      "id": "M21-V01",
      "group": "M21",
      "sourceQuestion": 21,
      "sourcePage": 5,
      "variant": 1,
      "origin": "variant",
      "type": "code",
      "question": "Fill exactly n bytes beginning at ptr with byte and return the original ptr. Give recognizable C code without calling memset or another memory-fill helper.",
      "code": "void *fill_bytes(void *ptr, unsigned char byte, size_t n);",
      "modelAnswer": "void *fill_bytes(void *ptr, unsigned char byte, size_t n) {\n    unsigned char *p = ptr;\n    for (size_t i = 0; i < n; ++i) p[i] = byte;\n    return ptr;\n}",
      "rubric": [
        "Use a character pointer to address individual bytes.",
        "Honor the exact bounds and the zero-length case.",
        "Write the requested byte value without changing bytes outside the range.",
        "Return the required pointer or count; preserve the original pointer when needed."
      ],
      "explanation": "Access storage one byte at a time through a character pointer. Follow this question’s exact range and return contract; the model is one valid implementation.",
      "verification": {
        "kind": "implementation",
        "cases": [
          {
            "setup": "unsigned char b[] = {9,9,9,9};",
            "invoke": "void *r = fill_bytes(b+1, 0xA5, 2);",
            "assert": "r == b+1 && b[0] == 9 && b[1] == 165 && b[2] == 165 && b[3] == 9"
          },
          {
            "setup": "unsigned char b[] = {9,9,9,9};",
            "invoke": "fill_bytes(b, 7, 0);",
            "assert": "b[0] == 9 && b[1] == 9 && b[2] == 9 && b[3] == 9"
          }
        ]
      },
      "note": "Assume all requested byte ranges fit in writable allocated objects and size calculations do not overflow. Required standard types are declared. Do not perform arithmetic directly on void *."
    },
    {
      "id": "M21-V02",
      "group": "M21",
      "sourceQuestion": 21,
      "sourcePage": 5,
      "variant": 2,
      "origin": "variant",
      "type": "code",
      "question": "Set exactly n bytes beginning at ptr to zero. Return no value. Give recognizable C code without calling memset or another memory-fill helper.",
      "code": "void zero_bytes(void *ptr, size_t n);",
      "modelAnswer": "void zero_bytes(void *ptr, size_t n) {\n    unsigned char *p = ptr;\n    for (size_t i = 0; i < n; ++i) p[i] = 0;\n}",
      "rubric": [
        "Use a character pointer to address individual bytes.",
        "Honor the exact bounds and the zero-length case.",
        "Write the requested byte value without changing bytes outside the range.",
        "Return the required pointer or count; preserve the original pointer when needed."
      ],
      "explanation": "Access storage one byte at a time through a character pointer. Follow this question’s exact range and return contract; the model is one valid implementation.",
      "verification": {
        "kind": "implementation",
        "cases": [
          {
            "setup": "unsigned char b[] = {9,9,9,9};",
            "invoke": "zero_bytes(b+1, 2);",
            "assert": "b[0] == 9 && b[1] == 0 && b[2] == 0 && b[3] == 9"
          },
          {
            "setup": "unsigned char b[] = {9,9,9,9};",
            "invoke": "zero_bytes(b, 0);",
            "assert": "b[0] == 9 && b[1] == 9 && b[2] == 9 && b[3] == 9"
          }
        ]
      },
      "note": "Assume all requested byte ranges fit in writable allocated objects and size calculations do not overflow. Required standard types are declared. Do not perform arithmetic directly on void *."
    },
    {
      "id": "M21-V03",
      "group": "M21",
      "sourceQuestion": 21,
      "sourcePage": 5,
      "variant": 3,
      "origin": "variant",
      "type": "code",
      "question": "Fill count bytes starting at buffer[start] with byte. Preserve all other bytes and return the original buffer pointer. Give recognizable C code without calling memset or another memory-fill helper.",
      "code": "unsigned char *fill_range(unsigned char *buffer, size_t start, size_t count, unsigned char byte);",
      "modelAnswer": "unsigned char *fill_range(unsigned char *buffer, size_t start, size_t count, unsigned char byte) {\n    for (size_t i = 0; i < count; ++i) buffer[start + i] = byte;\n    return buffer;\n}",
      "rubric": [
        "Use a character pointer to address individual bytes.",
        "Honor the exact bounds and the zero-length case.",
        "Write the requested byte value without changing bytes outside the range.",
        "Return the required pointer or count; preserve the original pointer when needed."
      ],
      "explanation": "Access storage one byte at a time through a character pointer. Follow this question’s exact range and return contract; the model is one valid implementation.",
      "verification": {
        "kind": "implementation",
        "cases": [
          {
            "setup": "unsigned char b[] = {9,9,9,9};",
            "invoke": "unsigned char *r = fill_range(b, 1, 2, 4);",
            "assert": "r == b && b[0] == 9 && b[1] == 4 && b[2] == 4 && b[3] == 9"
          },
          {
            "setup": "unsigned char b[] = {9,9,9,9};",
            "invoke": "fill_range(b, 0, 0, 4);",
            "assert": "b[0] == 9 && b[1] == 9 && b[2] == 9 && b[3] == 9"
          }
        ]
      },
      "note": "Assume all requested byte ranges fit in writable allocated objects and size calculations do not overflow. Required standard types are declared. Do not perform arithmetic directly on void *."
    },
    {
      "id": "M21-V04",
      "group": "M21",
      "sourceQuestion": 21,
      "sourcePage": 5,
      "variant": 4,
      "origin": "variant",
      "type": "code",
      "question": "Fill n bytes with byte, visiting them from the final byte backward to the first. Return ptr. Avoid unsigned-loop underflow. Give recognizable C code without calling memset or another memory-fill helper.",
      "code": "void *fill_reverse(void *ptr, unsigned char byte, size_t n);",
      "modelAnswer": "void *fill_reverse(void *ptr, unsigned char byte, size_t n) {\n    unsigned char *p = ptr;\n    while (n > 0) {\n        --n;\n        p[n] = byte;\n    }\n    return ptr;\n}",
      "rubric": [
        "Use a character pointer to address individual bytes.",
        "Honor the exact bounds and the zero-length case.",
        "Write the requested byte value without changing bytes outside the range.",
        "Return the required pointer or count; preserve the original pointer when needed."
      ],
      "explanation": "Access storage one byte at a time through a character pointer. Follow this question’s exact range and return contract; the model is one valid implementation.",
      "verification": {
        "kind": "implementation",
        "cases": [
          {
            "setup": "unsigned char b[] = {9,9,9,9};",
            "invoke": "void *r = fill_reverse(b+1, 6, 2);",
            "assert": "r == b+1 && b[0] == 9 && b[1] == 6 && b[2] == 6 && b[3] == 9"
          },
          {
            "setup": "unsigned char b[] = {9,9,9,9};",
            "invoke": "fill_reverse(b, 6, 0);",
            "assert": "b[0] == 9 && b[1] == 9 && b[2] == 9 && b[3] == 9"
          }
        ]
      },
      "note": "Assume all requested byte ranges fit in writable allocated objects and size calculations do not overflow. Required standard types are declared. Do not perform arithmetic directly on void *."
    },
    {
      "id": "M21-V05",
      "group": "M21",
      "sourceQuestion": 21,
      "sourcePage": 5,
      "variant": 5,
      "origin": "variant",
      "type": "code",
      "question": "Fill n bytes with alternating first and second byte values, beginning with first at offset zero. Return ptr. Give recognizable C code without calling memset or another memory-fill helper.",
      "code": "void *fill_alternating(void *ptr, unsigned char first, unsigned char second, size_t n);",
      "modelAnswer": "void *fill_alternating(void *ptr, unsigned char first, unsigned char second, size_t n) {\n    unsigned char *p = ptr;\n    for (size_t i = 0; i < n; ++i) {\n        p[i] = i % 2 == 0 ? first : second;\n    }\n    return ptr;\n}",
      "rubric": [
        "Use a character pointer to address individual bytes.",
        "Honor the exact bounds and the zero-length case.",
        "Write the requested byte value without changing bytes outside the range.",
        "Return the required pointer or count; preserve the original pointer when needed."
      ],
      "explanation": "Access storage one byte at a time through a character pointer. Follow this question’s exact range and return contract; the model is one valid implementation.",
      "verification": {
        "kind": "implementation",
        "cases": [
          {
            "setup": "unsigned char b[] = {9,9,9,9};",
            "invoke": "void *r = fill_alternating(b, 1, 2, 3);",
            "assert": "r == b && b[0] == 1 && b[1] == 2 && b[2] == 1 && b[3] == 9"
          },
          {
            "setup": "unsigned char b[] = {9,9,9,9};",
            "invoke": "fill_alternating(b, 1, 2, 0);",
            "assert": "b[0] == 9 && b[1] == 9 && b[2] == 9 && b[3] == 9"
          }
        ]
      },
      "note": "Assume all requested byte ranges fit in writable allocated objects and size calculations do not overflow. Required standard types are declared. Do not perform arithmetic directly on void *."
    },
    {
      "id": "M21-V06",
      "group": "M21",
      "sourceQuestion": 21,
      "sourcePage": 5,
      "variant": 6,
      "origin": "variant",
      "type": "code",
      "question": "Fill n bytes beginning offset bytes after ptr. Return the original ptr, not the start of the filled subrange. Give recognizable C code without calling memset or another memory-fill helper.",
      "code": "void *fill_after(void *ptr, size_t offset, unsigned char byte, size_t n);",
      "modelAnswer": "void *fill_after(void *ptr, size_t offset, unsigned char byte, size_t n) {\n    unsigned char *p = ptr;\n    for (size_t i = 0; i < n; ++i) p[offset + i] = byte;\n    return ptr;\n}",
      "rubric": [
        "Use a character pointer to address individual bytes.",
        "Honor the exact bounds and the zero-length case.",
        "Write the requested byte value without changing bytes outside the range.",
        "Return the required pointer or count; preserve the original pointer when needed."
      ],
      "explanation": "Access storage one byte at a time through a character pointer. Follow this question’s exact range and return contract; the model is one valid implementation.",
      "verification": {
        "kind": "implementation",
        "cases": [
          {
            "setup": "unsigned char b[] = {9,9,9,9};",
            "invoke": "void *r = fill_after(b, 1, 0, 2);",
            "assert": "r == b && b[0] == 9 && b[1] == 0 && b[2] == 0 && b[3] == 9"
          },
          {
            "setup": "unsigned char b[] = {9,9,9,9};",
            "invoke": "fill_after(b, 0, 0, 0);",
            "assert": "b[0] == 9 && b[1] == 9 && b[2] == 9 && b[3] == 9"
          }
        ]
      },
      "note": "Assume all requested byte ranges fit in writable allocated objects and size calculations do not overflow. Required standard types are declared. Do not perform arithmetic directly on void *."
    },
    {
      "id": "M21-V07",
      "group": "M21",
      "sourceQuestion": 21,
      "sourcePage": 5,
      "variant": 7,
      "origin": "variant",
      "type": "code",
      "question": "If count is zero or negative, write nothing. Otherwise fill count bytes with byte. In every case return ptr. Give recognizable C code without calling memset or another memory-fill helper.",
      "code": "void *fill_checked(void *ptr, unsigned char byte, int count);",
      "modelAnswer": "void *fill_checked(void *ptr, unsigned char byte, int count) {\n    unsigned char *p = ptr;\n    for (int i = 0; i < count; ++i) p[i] = byte;\n    return ptr;\n}",
      "rubric": [
        "Use a character pointer to address individual bytes.",
        "Honor the exact bounds and the zero-length case.",
        "Write the requested byte value without changing bytes outside the range.",
        "Return the required pointer or count; preserve the original pointer when needed."
      ],
      "explanation": "Access storage one byte at a time through a character pointer. Follow this question’s exact range and return contract; the model is one valid implementation.",
      "verification": {
        "kind": "implementation",
        "cases": [
          {
            "setup": "unsigned char b[] = {9,9,9,9};",
            "invoke": "void *r = fill_checked(b+1, 7, 2);",
            "assert": "r == b+1 && b[0] == 9 && b[1] == 7 && b[2] == 7 && b[3] == 9"
          },
          {
            "setup": "unsigned char b[] = {9,9,9,9};",
            "invoke": "fill_checked(b, 7, -2);",
            "assert": "b[0] == 9 && b[1] == 9 && b[2] == 9 && b[3] == 9"
          }
        ]
      },
      "note": "Assume all requested byte ranges fit in writable allocated objects and size calculations do not overflow. Required standard types are declared. Do not perform arithmetic directly on void *."
    },
    {
      "id": "M21-V08",
      "group": "M21",
      "sourceQuestion": 21,
      "sourcePage": 5,
      "variant": 8,
      "origin": "variant",
      "type": "code",
      "question": "Convert value to unsigned char, fill exactly n bytes with that byte, and return the original ptr. Assume 8-bit bytes. Give recognizable C code without calling memset or another memory-fill helper.",
      "code": "void *fill_value(void *ptr, int value, size_t n);",
      "modelAnswer": "void *fill_value(void *ptr, int value, size_t n) {\n    unsigned char *p = ptr;\n    unsigned char byte = (unsigned char)value;\n    for (size_t i = 0; i < n; ++i) p[i] = byte;\n    return ptr;\n}",
      "rubric": [
        "Use a character pointer to address individual bytes.",
        "Honor the exact bounds and the zero-length case.",
        "Write the requested byte value without changing bytes outside the range.",
        "Return the required pointer or count; preserve the original pointer when needed."
      ],
      "explanation": "Access storage one byte at a time through a character pointer. Follow this question’s exact range and return contract; the model is one valid implementation.",
      "verification": {
        "kind": "implementation",
        "cases": [
          {
            "setup": "unsigned char b[] = {9,9,9,9};",
            "invoke": "void *r = fill_value(b+1, 258, 2);",
            "assert": "r == b+1 && b[0] == 9 && b[1] == 2 && b[2] == 2 && b[3] == 9"
          },
          {
            "setup": "unsigned char b[] = {9,9,9,9};",
            "invoke": "fill_value(b, -1, 0);",
            "assert": "b[0] == 9 && b[1] == 9 && b[2] == 9 && b[3] == 9"
          }
        ]
      },
      "note": "Assume all requested byte ranges fit in writable allocated objects and size calculations do not overflow. Required standard types are declared. Do not perform arithmetic directly on void *."
    },
    {
      "id": "M21-V09",
      "group": "M21",
      "sourceQuestion": 21,
      "sourcePage": 5,
      "variant": 9,
      "origin": "variant",
      "type": "code",
      "question": "In n bytes beginning at ptr, replace only bytes currently equal to zero with byte. Return the number of zero bytes selected for replacement, even if byte is itself zero. Give recognizable C code without calling memset or another memory-fill helper.",
      "code": "size_t fill_zeros(void *ptr, unsigned char byte, size_t n);",
      "modelAnswer": "size_t fill_zeros(void *ptr, unsigned char byte, size_t n) {\n    unsigned char *p = ptr;\n    size_t count = 0;\n    for (size_t i = 0; i < n; ++i) {\n        if (p[i] == 0) { p[i] = byte; ++count; }\n    }\n    return count;\n}",
      "rubric": [
        "Use a character pointer to address individual bytes.",
        "Honor the exact bounds and the zero-length case.",
        "Write the requested byte value without changing bytes outside the range.",
        "Return the required pointer or count; preserve the original pointer when needed."
      ],
      "explanation": "Access storage one byte at a time through a character pointer. Follow this question’s exact range and return contract; the model is one valid implementation.",
      "verification": {
        "kind": "implementation",
        "cases": [
          {
            "setup": "unsigned char b[] = {9,9,9,9};",
            "invoke": "b[1] = 0; b[2] = 0; size_t r = fill_zeros(b, 5, 3);",
            "assert": "r == 2 && b[0] == 9 && b[1] == 5 && b[2] == 5 && b[3] == 9"
          },
          {
            "setup": "unsigned char b[] = {9,9,9,9};",
            "invoke": "fill_zeros(b, 5, 0);",
            "assert": "b[0] == 9 && b[1] == 9 && b[2] == 9 && b[3] == 9"
          }
        ]
      },
      "note": "Assume all requested byte ranges fit in writable allocated objects and size calculations do not overflow. Required standard types are declared. Do not perform arithmetic directly on void *."
    },
    {
      "id": "M21-V10",
      "group": "M21",
      "sourceQuestion": 21,
      "sourcePage": 5,
      "variant": 10,
      "origin": "variant",
      "type": "code",
      "question": "Fill n bytes beginning at ptr with byte, then return a pointer one byte past the filled range. For n = 0 return ptr. Give recognizable C code without calling memset or another memory-fill helper.",
      "code": "unsigned char *fill_end(void *ptr, unsigned char byte, size_t n);",
      "modelAnswer": "unsigned char *fill_end(void *ptr, unsigned char byte, size_t n) {\n    unsigned char *p = ptr;\n    for (size_t i = 0; i < n; ++i) *p++ = byte;\n    return p;\n}",
      "rubric": [
        "Use a character pointer to address individual bytes.",
        "Honor the exact bounds and the zero-length case.",
        "Write the requested byte value without changing bytes outside the range.",
        "Return the required pointer or count; preserve the original pointer when needed."
      ],
      "explanation": "Access storage one byte at a time through a character pointer. Follow this question’s exact range and return contract; the model is one valid implementation.",
      "verification": {
        "kind": "implementation",
        "cases": [
          {
            "setup": "unsigned char b[] = {9,9,9,9};",
            "invoke": "unsigned char *r = fill_end(b+1, 8, 2);",
            "assert": "r == b+3 && b[0] == 9 && b[1] == 8 && b[2] == 8 && b[3] == 9"
          },
          {
            "setup": "unsigned char b[] = {9,9,9,9};",
            "invoke": "fill_end(b, 8, 0);",
            "assert": "b[0] == 9 && b[1] == 9 && b[2] == 9 && b[3] == 9"
          }
        ]
      },
      "note": "Assume all requested byte ranges fit in writable allocated objects and size calculations do not overflow. Required standard types are declared. Do not perform arithmetic directly on void *."
    }
  ]
}
