OA. free
Free
Texas Instruments Data Structures & Algorithms Data Structures & Algorithms Medium

4.

Texas Instruments technical mcq question, verified with a worked answer. Free to practise - no sign-up.

Using structures 0 Previous Aptitude What will the following code snippet print when executed in a 32 bit system? Submitted typedef struct { Software float angle, radius; char *next; @O0 | Ee VECTOR v{10]; O:: printf("%d\n", sizeof(v)); 7 8 9 10 - A) 120 - B) 160 - C) 200 - D) 320 G&G a © G>

Choose one option.
Show answer & explanation
Answer: A. 120

Assuming the struct contains two floats (angle, radius) and one char pointer, on a 32-bit system the struct size is 12 bytes. Multiplying by an array size of 10 gives 120 bytes.

Step-by-step Derivation:
Step 1: Determine the size of each member in a 32-bit system.

  • float: 4 bytes
  • char * (pointer): 4 bytes (since 32-bit addressing)

Step 2: Check struct alignment.

  • Two floats = 4 + 4 = 8 bytes, char pointer = 4 bytes. Since all members are aligned to 4-byte boundaries, the struct size is 8 + 4 = 12 bytes with no extra padding.

Step 3: Apply the array multiplier.

  • VECTOR v[10] means 10 elements of 12 bytes each.
  • sizeof(v) = 10 * 12 = 120 bytes.

Step 4: Print result.

  • printf("%d\n", sizeof(v)) will output 120.