Top 20 C Programming Interview Questions and Answers (With Examples)
Top 20 C Programming Interview Questions and Answers (With Examples)
Preparing for a C programming interview? This guide covers the most frequently asked C interview questions with clear explanations and simple code examples. Perfect for students and freshers.
1. What is C Programming Language?
C is a general-purpose, procedural programming language used for system programming, embedded systems, and application development.
2. What is a pointer in C?
A pointer is a variable that stores the memory address of another variable.
int x = 10;
int *p = &x;
printf("%d", *p);
3. Difference between = and == ?
- = is assignment operator
- == is comparison operator
4. What is an array?
An array is a collection of similar data types stored in contiguous memory.
5. What is a function?
A function is a block of code that performs a specific task and can be reused.
6. What is recursion?
When a function calls itself, it is called recursion.
7. What is a structure?
A structure groups different data types under one name.
8. Difference between structure and union?
- Structure: Each member has its own memory
- Union: All members share the same memory
9. What is malloc()?
malloc() dynamically allocates memory in heap.
10. What is free()?
free() releases dynamically allocated memory.
11. What is a null pointer?
A pointer that does not point to any memory location.
12. What is a dangling pointer?
A pointer that points to deallocated memory.
13. What is file handling in C?
It allows reading and writing data to files using FILE pointer.
14. What is sizeof()?
Returns size of a data type in bytes.
15. What is typedef?
Creates an alias name for a data type.
16. What is volatile keyword?
Prevents compiler optimization on a variable.
17. What is static variable?
Retains its value between function calls.
18. What is segmentation fault?
An error caused by accessing invalid memory.
19. Difference between call by value and call by reference?
- Call by value: Copy of variable is passed
- Call by reference: Address is passed
20. What is the use of header files?
Header files contain function declarations and macros.
Conclusion
These C interview questions cover the most important fundamentals. Master these topics and practice coding daily to crack technical interviews with confidence.
Next Post: Pointers in C Explained Simply – Memory, Arrays, and Functions
Comments
Post a Comment