ProgrammingModerate
Assume natural alignment with 4-byte int. What is sizeof(struct R[5]) where struct R is the eight-byte type from the previous record?
- A. 32
- B. 48
- C. 40
- D. 35
Correct answer: C. 40
An array of structs is laid out contiguously with no extra padding between elements, so five copies of an 8-byte struct take 40 bytes.
More C Programming questions
- struct Q { char name[6]; double score; char tag; }; with 8-byte double and natural alignment. What is sizeof(struct Q)?
- Assume natural alignment: char 1, double 8. What is sizeof(struct T) for struct T { char a; double d; char b[3]; }?
- Binary search with lo = 0, hi = n - 1 on n = 1000 sorted records, looking for a key not in the array, performs how many probes at most?
- Insertion sort is applied to a = {5, 2, 4, 6, 1, 3} and each element moved one slot to the right while shifting counts as one move. How…
- A selection sort swaps the minimum into place, but only when the minimum is not already in place. How many swaps does it make on {7, 2, 9…
- Records are counted into buckets by key 0 to 2 in a stable counting sort. Input: Ann 2, Bob 0, Cy 2, Dee 1, Eve 0. What is the output…