99 questions in 9 topics
C Basics Interview Questions
The basics from campus placements and first rounds: building a program, data types, storage classes and functions.
- What is C, and why is it still used?
- What are the stages of compiling a C program?
- What are the basic data types in C and their sizes?
- What is the difference between a declaration and a definition in C?
C Pointers Interview Questions
The topic C interviews spend most time on: invalid pointers, const, function pointers and pointer arithmetic.
- What is a pointer in C?
- What is the difference between a NULL pointer, a void pointer, a dangling pointer and a wild pointer?
- What is a void pointer, and why can you not dereference it?
- Which variable does
**q = 20change whenqpoints top?
C Arrays and Strings Interview Questions
Arrays, how they decay to pointers, null-terminated strings and the functions that overflow buffers.
- What does
sizeofreturn for an array versus a pointer to it? - What do
sizeofandstrlenreturn forchar s[] = "hello"? - What is the difference between
char s[] = "hi"andchar *s = "hi"? - Write a C function that reverses a string in place.
C Memory Management Interview Questions
Dynamic allocation, stack and heap, leaks and the mistakes that cause crashes.
- What is the difference between stack and heap memory in C?
- What is the difference between
malloc,callocandrealloc? - What is wrong with
p = realloc(p, new_size);? - What is a memory leak, and how do you find one in C?
C Structures and Unions Interview Questions
Structs, unions, padding and the self-referential structs linked lists are made of.
- What is the difference between a structure and a union in C?
- Does member order change the
sizeofof a struct? - Does assigning one struct to another copy it or share it?
- What does
typedefdo, and why is it used with structs?
C Preprocessor Interview Questions
Macros, include guards and conditional compilation, with the macro traps that become output questions.
- What is the C preprocessor?
- What does
SQUARE(2 + 3)give with#define SQUARE(x) x * x? - How many times is
iincremented inMAX(i++, j)? - What is the difference between a macro and a function?
C Programming Output Questions
Predict-the-output questions from written tests; each one has a defined result on this build.
- What does
printfreturn when you nest it inside anotherprintf? - Does
sizeof(i++)incrementi? - Is
-1 < 1utrue in C? - What runs when a
switchcase has nobreak?
Embedded C Interview Questions
Where firmware interviews start: volatile, register bit operations, fixed-width types and endianness.
- What does the
volatilekeyword do? - Can a variable be both
constandvolatile? - How do you set, clear, toggle and check a bit in C?
- What is
0x0Fafter setting bit 6 and clearing bit 0?
Advanced C Interview Questions
Linkage, aliasing, generic code, variadic functions and the corners of the standard that cause real bugs.
- What is linkage in C, and how do
staticandexternaffect it? - What is the strict aliasing rule?
- How do you write type-generic code in C?
- How do variadic functions like
printfwork, and how do you write one?
Frequently Asked Questions
How should I prepare for a C programming interview?
Learn the fundamentals until you can predict the output of short programs: pointers, arrays, strings, structs, storage classes and dynamic memory. Then write the classics by hand in C (string reverse, linked list, binary search, bit counting) and finish with undefined behavior and the preprocessor.
What C topics are asked of freshers, and what of experienced candidates?
Freshers get definitions and output questions: data types, static, pointers, strings, structs versus unions, macros and recursion. Experienced candidates get memory layout, malloc internals, debugging tools, linkage, strict aliasing, undefined behavior and volatile, and must explain why.
Do I need data structures and algorithms for a C interview?
For most software roles, yes: expect a coding question on arrays, strings, linked lists or bits, where pointer handling is part of the test. Embedded roles ask more about registers and interrupts.
How long does it take to prepare for a C interview?
If you already write C, two to three weeks on the topics here and 30 to 50 small problems is usually enough. If C is new to you, plan on one to two months, mostly on pointers and memory.
Which C standard should I know for interviews?
Answer in terms of C99 and C11, which most code targets, and mention C23 (ckd_add, constexpr) only when relevant. Know that // comments, <stdbool.h> and declarations inside for are C99.