C Interview Questions
Ten spines of the C questions that come up when time is short: string and pointer traps, linked-list rewiring, bit tricks and const rules, each one checked to give the same answer on every machine. The items built on a premise the language does not actually guarantee - char signedness, argument evaluation order, signed overflow - explain why, instead of faking a single output.
Who it is for
Preparing, and short of time.
For someone confident in the language who wants the traps, the edge cases and the interview questions.
You will get the most out of it if you have written C recently enough to read it without effort, and have been surprised by it at least once. If you are picking the language up for the first time, start with C Essentials and come back to this one.
It is also built for interview preparation: the questions are the ones that get asked because they separate people who have read the documentation from people who have hit the behaviour in production.
How long it takes
90 graded questions at roughly 45 seconds each is about 68 minutes of answering in total.
At the default five questions a day, and because the session mixes in your other courses, expect around 18 days — call it 3 weeks — to see everything once, plus a few weeks of thinning reviews after that before it is all mastered.
A question is mastered on the third correct answer, once the gap between reviews has grown past a week — so a course cannot be finished in a weekend however long you sit with it.
Question mix
- 60 multiple choice
- 10 concept cards
- 10 predict the output
- 10 put it in order
- 10 matching questions
Syllabus
What you will be asked about
-
01
Reversing a String In Place
Reverse a character array in place with a two-index swap loop, and say why a string literal cannot take the same treatment.
-
02
Array vs Pointer Parameters
Predict what an array parameter does and does not carry across a function call, and where const attaches to it.
-
03
String Literal vs Char Array
Tell a writable char array apart from a pointer into a string literal, and say what each may legally do.
-
04
Linked-List Manipulation
Trace pointer updates when inserting, deleting or reversing a singly linked list built from stack nodes.
-
05
Static and Scope
Predict when a static local keeps its value and when static at file scope only restricts visibility.
-
06
Bit Manipulation on Unsigned Types
Use shifts, masks and unsigned wraparound to answer bit-level questions that hold on every machine.
-
07
String Parsing
Walk a C string by hand with pointers or indices to parse it without assuming more than the loop actually checks.
-
08
Const Correctness
Use const to state what a function promises not to change, and predict which promises the compiler enforces.
-
09
Swap Without a Temporary
Explain the XOR and add/subtract swap tricks, and say precisely why a temp variable is the better answer.
-
10
Recognising a Wrong Premise
Identify when a question about C output presumes an answer the standard does not guarantee, and say precisely why.
8 more topics, and all 90 questions
C Interview Questions is a Pro course. One subscription opens it and every other course in the catalogue, including the ones still being written.
A question from this course
Reversing a String In Place
What does this print?
#include <stdio.h>
#include <string.h>
int main(void) {
char s[] = "abcd";
int left = 0, right = (int)strlen(s) - 1;
while (left < right) {
char t = s[left];
s[left] = s[right];
s[right] = t;
left++; right--;
}
printf("%s\n", s);
return 0;
}
Show the answer
A dcba
The loop swaps the outermost pair first (s[0] with s[3]) and works inward, so the whole string flips end to end. You may have expected the adjacent-pair mistakes among the wrong options if you traced the indices as a fixed pairing rather than two indices converging toward the middle.
The rest of the track
C at every depth
C Essentials
Covers C's basic types and integer promotion, operator precedence, control flow, functions and parameters, arrays, strings as char arrays, introductory pointers, printf specifiers, scope and lifetime, and const - the syntax a beginner reaches for first. Every item runs against a real compiler, so the surprising cases are proven rather than asserted.
C Core
Covers pointer arithmetic, arrays decaying to pointers, where const actually applies, struct assignment, malloc/free and ownership, the strcpy family, integer conversion and promotion, the ternary and comma operators, and static at file and block scope. Aimed at someone who already writes C daily but has never had the gap between what compiles and what is correct made explicit.
C Data & Collections
Arrays decay to pointers the instant they cross a function boundary, and every container in C is really addresses and strides under a comfortable-looking syntax. This course puts pressure on that comfort: row-major layout, struct-embedded arrays, flexible array members, qsort comparators, realloc growth, and hand-built linked lists, until the mental model matches what the compiler actually does.
C Errors & Edge Cases
Most C code you have seen handles the case where everything works; this course is about the returns, allocations, and reads that fail, and what checking them properly looks like in practice. It covers return codes versus errno, partial transfers, strtol and strncpy's sharp edges, off-by-one bounds, integer overflow before malloc, and the goto-cleanup and assert idioms that keep a program correct under failure.
C Standard Library
For a reader who reaches for a dependency before checking what the standard library already does. Works through string.h, stdio.h, stdlib.h, ctype.h, time.h, and the fixed-width types in stdint.h and limits.h, with every answer checked against what the C standard actually guarantees.
C Idioms & Pitfalls
For a reader who is fluent in C but still writes it like another language. Works through the array-length macro's function-parameter trap, const placement, designated initializers, compound literals, both meanings of static, header guards, function-pointer dispatch tables, restrict, X-macros, and the copy-semantics mistakes that leak in from Java, Python, or C++.
C Advanced
Pointers to pointers, function pointers, unions, variadic functions, the preprocessor, recursion, setjmp/longjmp, opaque pointers and _Generic - the traps a confident C developer trips over. Every answer here is guaranteed by the standard, never by one compiler's mood on one machine.
C Performance
Complexity you can count instead of guess: linear scans, strlen in a loop condition, memcpy versus a byte loop, realloc growth, buffered output, struct passing, static linkage, and hoisting invariant work. Every answer here is an operation count or a call count, checked by running the code - never a clock reading.
C Testing
Ten spines on testing C the way it actually gets tested: hand-rolled CHECK macros, what NDEBUG deletes from an assert, seams built from function pointers, forcing the allocation-failure branch on purpose, and comparing floating point with a tolerance instead of ==. Every graded snippet is checked to give the same answer on every machine, and several items exist to catch a test that looks reasonable but could never actually fail.
Start C Interview Questions
in tomorrow’s session.
Enrol and this course joins your daily five, mixed in with everything else you are studying — 90 questions spread over about 18 days rather than dropped on you at once.
Browse the catalogue