Freshers memorise definitions, then freeze when an interviewer says, "Dry-run this" or "What does this print?" C sits close to memory, so a strong answer explains what exists, where it lives, and when it changes.
Here are 40 questions grouped by the ideas interviewers probe, followed by the answering method you can use at a whiteboard.
How C interviews are scored, not just recalled
Interviewers use pointers, memory, and undefined behaviour to test runtime reasoning. They may accept a definition, then change one line and ask for the effect.
Identify each object's type and lifetime, draw the cells, apply the statement, then state the output. If C does not define an outcome, say undefined behaviour instead of guessing.
Pointers and memory: the core 10
What does a pointer hold? An address of an object or function of a compatible type, or a null pointer value that points to no object.
What is a pointer to pointer? A pointer whose target is another pointer, such as
int **pp;*ppis anint *and**ppis anint.What does pointer arithmetic do? Adding one to
int *padvances by oneint, provided the result stays within the same array object or one past it.What is array-to-pointer decay? In most expressions, an array name converts to a pointer to its first element; important exceptions include operands of
sizeofand unary&.How do
arrand&arrdiffer? They commonly have the same numeric address, butarrdecays to a pointer to the first element while&arrpoints to the entire array and steps by the whole array size.Dangling pointer vs wild pointer? A dangling pointer refers to an object whose lifetime has ended; a wild pointer is uninitialised and holds an indeterminate value.
What is a null pointer? A pointer value guaranteed not to compare equal to the address of any object or function; dereferencing it is undefined behaviour.
What is
void *? A generic object-pointer type that can hold an object address; convert it to an appropriate typed pointer before dereferencing.What is a function pointer? A pointer that stores a function address and can call a function with the matching signature, often used for callbacks.
const int *pvsint * const p? The first prevents changing the pointed value throughp; the second prevents makingppoint somewhere else.
Pointers in C for GATE adds memory diagrams.
Worked example: pass-by-pointer mutation
Use this exact program:
void inc(int *p) {
(*p)++;
}
int main() {
int a = 5;
inc(&a);
printf("%d\n", a);
}Trace it in memory:
alives inmain's stack frame, say at address0x7ffe1004, holding5.inc(&a)passes that address; insideinc,pholds0x7ffe1004.(*p)++reads the cell reached throughpand writes6to0x7ffe1004.Back in
main,ais now6; the output is6.
If inc took int p by value, a would stay 5 because only a copy would change. Here, the value copied into p is a's address.

Storage, memory layout and lifetime: the core 10
Stack vs heap? Automatic local objects usually have block lifetime and are commonly stack-backed; dynamically allocated objects remain until
freeand come from managed dynamic storage.What does
mallocdo? It allocates an uninitialised byte block and returnsvoid *, or a null pointer on failure.How do
callocandreallocdiffer?callocallocates an array and zero-initialises its bytes;reallocchanges an existing allocation and may move it.Why call
free? It ends the lifetime of allocated storage; using that pointer to access the freed object afterwards is invalid.What is a memory leak? Allocated memory becomes unreachable without being freed, so the program can no longer release or reuse it deliberately.
What is a static local's lifetime? It exists for the entire program and retains its value between calls, although its name remains block-scoped.
staticvsexternat file scope?staticgives internal linkage;externdeclares a name whose definition can have external linkage elsewhere.What causes a segmentation fault? Common causes include invalid dereferences, writing read-only storage, out-of-bounds access, and stack exhaustion; C does not guarantee that particular signal.
sizeofarray vs pointer? In the array's defining scope,sizeof arris the whole array size; after decay or in a function parameter,sizeof pis only the pointer size.Can you modify a string literal or read an uninitialised automatic variable? No safe result is defined: modifying a literal is undefined behaviour, and reading an indeterminate automatic value can also be undefined behaviour.
Language semantics that trip people: the core 10
i++vs++i? Both incrementi; postfix yields the old value while prefix yields the new value.What does
i = i++do? It has undefined behaviour in C because modifications ofiare unsequenced; never offer a numeric answer.How does integer division work? With integer operands, the fractional part is discarded towards zero, so
7 / 2is3.What happens in character arithmetic? A
charis promoted to an integer type before arithmetic, so'A' + 1can be printed as'B'with%con ordinary C implementations.What is implicit type promotion? Narrow integer types commonly promote to
intorunsigned int, and mixed arithmetic then follows the usual conversions.#definevsconst? A macro is token substitution with no C type; aconstobject has a type, scope, and storage semantics.What is the macro argument trap? Write
#define SQR(x) ((x) * (x)); missing parentheses breaks expressions, and passingi++still causes multiple evaluation.Struct vs union size? A struct provides storage for every member plus padding; a union provides shared storage large and aligned enough for its largest-demanding member.
Name two useful bit tricks. XOR can swap two distinct integer objects without a temporary, and positive
nis a power of two when(n & (n - 1)) == 0.Switch fallthrough,
break, andcontinue? A case falls through withoutbreak;breakexits the switch or loop, whilecontinuestarts the next loop iteration.
Output and dry-run rapid fire: the remaining 10
# | Snippet | Interview-safe answer |
|---|---|---|
1 |
| Prints |
2 |
| Increments first and prints |
3 |
| Prints |
4 |
| Prints |
5 |
| Prints |
6 |
| Ends with |
7 |
| Prints |
8 |
| Prints |
9 |
| Undefined behaviour due to unsequenced modifications of |
10 |
| Undefined behaviour; there is no valid output to predict. |
How to answer under pressure: the short version
Reason about memory aloud, distinguish values from addresses, and name undefined behaviour. Technical interview prep: OS, DBMS, CN and OOP questions freshers face places C inside the wider plan.
Next, work the concept and MCQ sets in the C Programming course. KnowledgeGate has about 900 published C Programming questions for follow-up practice. For the rest of the drive, combine that work with the Mera Placement Hoga Anushasan bundle or browse the Placement Preparation catalogue.




