With 1-byte chars, 2-byte shorts, 4-byte ints and 8-byte doubles, each aligned to its size, no field reordering, and padding for alignment, how much space does this array use? struct { short s; char c; short t; char d; double r; int i; } A[10];
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: C. 240 bytes
Explanation
s at 0–1, c at 2, pad, t at 4–5, d at 6, pad to 8, r at 8–15, i at 16–19, then pad to 24 so the next element's double is aligned. 24 × 10 = 240 bytes.
More Programming Languages and Computer Graphics questions
- Consider the Java function: public static float f(long m, long n) { float result = (float)m / (float)n; if (m < 0 || n < 0) return 0.0f; el…
- In the context of 3D Computer graphics, which of the following statements is/are correct? (A) Under perspective projection, each set of par…
- Concerning phong shading and Gouraud shading in a 3D scene, which of the following statements are true? (A) Gouraud shading requires more c…
- Match List-I with List-II. List I gives matrices representing 2D transformations and List-II shows the corresponding transformation diagram…
- Given below are different properties of 3D projections from A-D. Identify the correct order on the basis of property true of (i) a perspect…
- Given below are two statements: Statement I : Bezier curves are curves that interpolate all of their control points. Statement II : A cubic…