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 will be the output of sizeof(union test) if union has members: int a, char b, float c?
Answer: A
Union size equals the size of its largest member. Here, both int and float are 4 bytes (largest), so sizeof(union test) = 4 bytes.
Q.582Easy
Which keyword is used to define a structure in C?
Answer: B
The 'struct' keyword is used to define structures in C. 'class' is used in C++ and Java.
Q.583Easy
What is the size of the following structure? struct point { int x; int y; float z; };
Answer: B
int x = 4 bytes, int y = 4 bytes, float z = 4 bytes. Total = 12 bytes (no padding in this case on most systems).
Q.584Easy
Can we pass a structure variable to a function in C?
Answer: C
Structures can be passed by value (copy of structure) or by reference (using pointers to structure).
Q.585Medium
What happens when you initialize a structure variable without assigning values?
Answer: B
Uninitialized local structure variables contain garbage values. Global structures are automatically initialized to zero.
Q.586Medium
Which of the following correctly declares a pointer to a structure?
Answer: A
Correct syntax is 'struct typename *pointerName;'. Option A follows proper declaration syntax.
Q.587Medium
What is the difference between struct and typedef struct?
Answer: B
typedef struct creates an alias, so you can declare variables directly using the alias name without repeating 'struct'.
Q.588Medium
What will be printed? struct s { int a; char b; int c; }; printf("%lu", sizeof(struct s));
Answer: B
Due to memory alignment/padding: int a(4) + char b(1) + 3 padding bytes + int c(4) = 12 bytes.
Q.589Medium
How do you access a member of a structure using a pointer?
Answer: B
The arrow operator (->) is used to access structure members through a pointer. Dot (.) is for direct variables.
Q.590Medium
What is the purpose of padding in structures?
Answer: B
Padding ensures that structure members are aligned in memory according to their natural boundaries, improving CPU access speed.
Q.591Medium
Consider: union u { int x; double y; }; What is sizeof(u)?
Answer: B
The size of a union is equal to its largest member. double is typically 8 bytes, which is larger than int (4 bytes).
Q.592Hard
Which statement is true about nested structures in C?
Answer: B
C allows structures to have other structures as members. This is called nested structures and is a common practice.
Q.593Hard
What happens if you assign a union member and then access another member? struct u { int a; char b; }; u.a = 257; printf("%d", u.b);
Answer: B
In a union, both members share memory. 257 in binary is 100000001. u.b (char) reads only the LSB, which is 1.
Q.594Hard
How can you initialize a structure array of 10 elements partially in C?
Answer: D
Both {0} and {} will initialize all members to zero. These are equivalent in C99 and later standards.
Q.595Hard
What is the difference between self-referential and recursive structures?
Answer: B
Self-referential structures contain pointers to the same structure type (like linked list nodes). Recursion refers to function calls, not structures.
Q.596Hard
Given union test { int x; char y[4]; }; If you set y[0]=65, y[1]=66, what happens to x?
Answer: C
Since union members share memory, setting y[0]=65 and y[1]=66 overwrites the int x value. The exact value depends on endianness.
Q.597Easy
Which of the following is a key difference between struct and union in C?
Answer: B
In unions, all members share the same memory location, so only one member can hold a value at a time. In structs, each member has its own memory space.
Q.598Easy
What will be the output of sizeof() for the following union? union data { int a; float b; double c; }
Answer: B
The size of a union is the size of its largest member. Here, double (8 bytes) is the largest, so sizeof(union data) = 8 bytes.
Q.599Easy
In C, what is a self-referential structure?
Answer: A
A self-referential structure contains a pointer to its own type, commonly used in creating linked lists, trees, and other data structures.
Q.600Easy
Which keyword is used to define a new name for a structure in C?
Answer: B
The typedef keyword creates an alias for a data type, allowing you to use a shorter name instead of the full struct declaration.