Entrance Exams
Govt. Exams
For nested structures accessed through an object, use the dot operator multiple times: obj.in.value accesses the value member of the inner structure.
sizeof(int) = 4 bytes, sizeof(pointer) = 8 bytes (on 64-bit systems). Total = 12 bytes. Pointers are fixed size regardless of what they point to.
Due to padding: int (4) + padding (4) + double (8) + char (1) + padding (3) = 24 bytes. The structure aligns to the largest member size.
The size of a union is equal to its largest member. double is typically 8 bytes, which is larger than int (4 bytes).
Padding ensures that structure members are aligned in memory according to their natural boundaries, improving CPU access speed.
The arrow operator (->) is used to access structure members through a pointer. Dot (.) is for direct variables.
struct s { int a; char b; int c; }; printf("%lu", sizeof(struct s));
Due to memory alignment/padding: int a(4) + char b(1) + 3 padding bytes + int c(4) = 12 bytes.
typedef struct creates an alias, so you can declare variables directly using the alias name without repeating 'struct'.
Correct syntax is 'struct typename *pointerName;'. Option A follows proper declaration syntax.
Uninitialized local structure variables contain garbage values. Global structures are automatically initialized to zero.