C questions in placement tests and university exams are rarely about syntax alone. Most of what you will find here is output prediction, pointer arithmetic, arrays and strings, structures and unions, storage classes, recursion, and file handling. The explanations walk through memory behaviour step by step, which is usually where the confusion sits rather than in the code itself.
What happens if you attempt to assign one structure variable to another of the same type?
Answer: B
In C, you can assign one structure variable to another of the same type, and all members are copied (shallow copy).
Q.62Medium
Which of the following is a valid declaration of nested structure?
Answer: C
Both nested structure definitions (defining B inside A and declaring B as member) are valid in C.
Q.63Medium
What is the primary advantage of using unions in embedded systems?
Answer: A
Unions are primarily used in embedded systems to conserve memory by allowing multiple members to share the same memory location.
Q.64Hard
In a structure, what does the #pragma pack(1) directive do?
Answer: A
#pragma pack(1) removes padding, making members occupy consecutive memory locations for compact storage.
Q.65Easy
Which of the following correctly demonstrates a typedef for a structure?
Answer: A
The correct syntax for typedef struct is: typedef struct { members } StructName;
Q.66Hard
If a structure contains a flexible array member, where must it be declared?
Answer: B
A flexible array member must be the last member of a structure. This is a C99 feature used for dynamic-sized arrays.
Q.67Medium
How can you create a structure that can hold either an integer or a floating-point number, but not both simultaneously?
Answer: B
A union is the appropriate choice when you need to store different data types but only one value at a time.
Q.68Medium
What is the difference between 'struct' and 'typedef struct' in C?
Answer: B
typedef struct creates a type alias, allowing you to declare variables without using the 'struct' keyword each time.
Q.69Hard
In competitive programming, when implementing a graph using adjacency lists, which data structure is most suitable?
Answer: B
An array of structures, where each structure contains a linked list (using self-referential pointers), is ideal for adjacency list representation.
Q.70Medium
What will be the output if you read a union member that was not last written to?
Answer: A
Reading a union member that wasn't last written gives unpredictable results (garbage value or leftover bits from previous member).
Q.71Easy
Which of the following is the correct way to initialize a structure in C?
Answer: A
Structures must be initialized at declaration time using curly braces. Assignment of initializer list is not valid after declaration.
Q.72Hard
If you have a structure with bit fields, which statement about their behavior is true?
Answer: A
Bit fields save memory by storing multiple values in single bytes, but behavior varies by compiler/platform, and you cannot take addresses of bit field members.
Q.73Medium
In a nested structure scenario, how do you access a member of the inner structure?
Answer: C
Use dot operator (.) for direct structure variables and arrow operator (->) for pointers, or combinations for nested access.
Q.74Easy
Which of the following statements about structures is TRUE?
Answer: B
A structure allows grouping of different data types. Padding may be added by the compiler for alignment.
Q.75Medium
What is the size of the following structure on a 32-bit system? struct Point { char c; int x; double y; }
Answer: D
char(1) + padding(3) + int(4) + double(8) = 16 bytes minimum, but alignment to double boundary makes it 24 bytes.
Q.76Easy
Consider the following code: struct Data { int a; char b; }; struct Data d = {10, 'A'}; Which method of initialization is used here?
Answer: B
Values are assigned in the order they appear in the structure definition, which is positional initialization.
Q.77Easy
What is the primary difference between a struct and a union in C?
Answer: A
In a union, all members occupy the same memory space, while struct members have individual memory locations.
Q.78Medium
What will be the output of this code? union Data { int a; char b; }; union Data d; d.a = 257; printf("%d %c", d.a, d.b);
Answer: C
Union shares memory. 257 in int format overwrites the char. On a little-endian system, only the lower byte (1) is stored in the char portion.
Q.79Easy
Which of the following correctly demonstrates accessing a member of a pointer to a structure?
Answer: B
Both (*ptr).member and ptr->member are valid. Option B uses explicit dereferencing, while the arrow operator is syntactic sugar for this.
Q.80Medium
What is the size of the following union? union Test { int a[5]; char b[10]; double c; }
Answer: B
Union size equals the largest member. int[5] = 20 bytes, char[10] = 10 bytes, double = 8 bytes. Maximum is 20 bytes.