C Programming Interview Questions and Answers

Practice every question in this topic using expandable answers and interview tips. Answer aloud first, then open the explanation.

Back to the complete interview hub

Read question Answer aloud Review
Q1. What is C language? [Easy]

Answer: C is a high-level, general-purpose procedural programming language developed by Dennis Ritchie at Bell Labs in 1972, widely used for OS, system tools, and embedded programming.

Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.

Q2. What are the key features of C? [Easy]

Answer: Features include simplicity, speed, modularity (functions), portability, low-level memory access with pointers, dynamic memory allocation, and rich operators.

Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.

Q3. What is a variable in C? [Easy]

Answer: A variable is a named memory location used to store a value of a specific data type that can be modified during program execution.

Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.

Q4. What are fundamental data types in C? [Easy]

Answer: Primary data types in C are int (integer), float (single precision decimal), double (double precision decimal), char (character), and void (valueless).

Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.

Q5. What is a constant in C? [Easy]

Answer: A constant is a literal value or variable defined using the 'const' keyword or '#define' directive whose value cannot be altered after declaration.

Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.

Q6. What is a pointer in C? [Easy]

Answer: A pointer is a variable that stores the memory address of another variable rather than a direct value.

Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.

Q7. What is the difference between & and * operators in pointers? [Medium]

Answer: & (address-of operator) returns the memory address of a variable. * (dereference operator) accesses the value stored at the address pointed to by a pointer.

Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.

Q8. What is an array in C? [Easy]

Answer: An array is a fixed-size collection of items of the same data type stored in contiguous memory locations accessed via zero-based indices.

Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.

Q9. What is a string in C? [Easy]

Answer: A string in C is a sequence of characters stored as a one-dimensional char array terminated by a null character ('\0').

Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.

Q10. What is a structure (struct) in C? [Medium]

Answer: A structure is a user-defined data type that allows combining variables of different data types into a single unit using the 'struct' keyword.

Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.

Q11. What is a union in C and how is it different from a structure? [Medium]

Answer: A union is a custom data type where all member variables share the exact same memory location, meaning only one member can hold a value at any given time.

Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.

Q12. What is dynamic memory allocation in C? [Medium]

Answer: Dynamic memory allocation allocates memory at runtime on the Heap using stdlib functions: malloc(), calloc(), realloc(), and free().

Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.

Q13. What is the difference between malloc() and calloc()? [Medium]

Answer: malloc() allocates raw uninitialized memory block. calloc() allocates memory for multiple elements and initializes all allocated bytes to zero.

Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.

Q14. What is a dangling pointer? [Hard]

Answer: A dangling pointer is a pointer that continues referencing a memory location that has already been deallocated using free().

Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.

Q15. What is a NULL pointer? [Hard]

Answer: A NULL pointer is a pointer initialized with NULL or address 0, explicitly indicating that it points to no valid memory location.

Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.

Q16. What is recursion in C? [Hard]

Answer: Recursion is a programming technique where a function calls itself directly or indirectly until a base condition is met to prevent stack overflow.

Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.

Q17. What is the difference between call by value and call by reference in C? [Easy]

Answer: Call by value passes a copy of variable values (modifications do not affect original). Call by reference passes pointer addresses, allowing direct variable mutation.

Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.

Study checklist

  1. Explain the answer without reading.
  2. Write one small example.
  3. Compare framework or database version differences in official documentation.

C Programming Interview Questions and Answers

Practice one question at a time. Read the question, answer aloud, then compare your explanation with the answer.

← Back to the complete interview hub

Study method: define the concept, give a small example, and mention one practical use or limitation.

Q1. What is C language?

Easy

Answer: C is a high-level, general-purpose procedural programming language developed by Dennis Ritchie at Bell Labs in 1972, widely used for OS, system tools, and embedded programming.

Interview tip: Use a short example and connect the answer to real project work.

Q2. What are the key features of C?

Easy

Answer: Features include simplicity, speed, modularity (functions), portability, low-level memory access with pointers, dynamic memory allocation, and rich operators.

Interview tip: Use a short example and connect the answer to real project work.

Q3. What is a variable in C?

Easy

Answer: A variable is a named memory location used to store a value of a specific data type that can be modified during program execution.

Interview tip: Use a short example and connect the answer to real project work.

Q4. What are fundamental data types in C?

Easy

Answer: Primary data types in C are int (integer), float (single precision decimal), double (double precision decimal), char (character), and void (valueless).

Interview tip: Use a short example and connect the answer to real project work.

Q5. What is a constant in C?

Easy

Answer: A constant is a literal value or variable defined using the 'const' keyword or '#define' directive whose value cannot be altered after declaration.

Interview tip: Use a short example and connect the answer to real project work.

Q6. What is a pointer in C?

Easy

Answer: A pointer is a variable that stores the memory address of another variable rather than a direct value.

Interview tip: Use a short example and connect the answer to real project work.

Q7. What is the difference between & and * operators in pointers?

Medium

Answer: & (address-of operator) returns the memory address of a variable. * (dereference operator) accesses the value stored at the address pointed to by a pointer.

Interview tip: Use a short example and connect the answer to real project work.

Q8. What is an array in C?

Easy

Answer: An array is a fixed-size collection of items of the same data type stored in contiguous memory locations accessed via zero-based indices.

Interview tip: Use a short example and connect the answer to real project work.

Q9. What is a string in C?

Easy

Answer: A string in C is a sequence of characters stored as a one-dimensional char array terminated by a null character ('\0').

Interview tip: Use a short example and connect the answer to real project work.

Q10. What is a structure (struct) in C?

Medium

Answer: A structure is a user-defined data type that allows combining variables of different data types into a single unit using the 'struct' keyword.

Interview tip: Use a short example and connect the answer to real project work.

Q11. What is a union in C and how is it different from a structure?

Medium

Answer: A union is a custom data type where all member variables share the exact same memory location, meaning only one member can hold a value at any given time.

Interview tip: Use a short example and connect the answer to real project work.

Q12. What is dynamic memory allocation in C?

Medium

Answer: Dynamic memory allocation allocates memory at runtime on the Heap using stdlib functions: malloc(), calloc(), realloc(), and free().

Interview tip: Use a short example and connect the answer to real project work.

Q13. What is the difference between malloc() and calloc()?

Medium

Answer: malloc() allocates raw uninitialized memory block. calloc() allocates memory for multiple elements and initializes all allocated bytes to zero.

Interview tip: Use a short example and connect the answer to real project work.

Q14. What is a dangling pointer?

Hard

Answer: A dangling pointer is a pointer that continues referencing a memory location that has already been deallocated using free().

Interview tip: Use a short example and connect the answer to real project work.

Q15. What is a NULL pointer?

Hard

Answer: A NULL pointer is a pointer initialized with NULL or address 0, explicitly indicating that it points to no valid memory location.

Interview tip: Use a short example and connect the answer to real project work.

Q16. What is recursion in C?

Hard

Answer: Recursion is a programming technique where a function calls itself directly or indirectly until a base condition is met to prevent stack overflow.

Interview tip: Use a short example and connect the answer to real project work.

Q17. What is the difference between call by value and call by reference in C?

Easy

Answer: Call by value passes a copy of variable values (modifications do not affect original). Call by reference passes pointer addresses, allowing direct variable mutation.

Interview tip: Use a short example and connect the answer to real project work.

Quick revision checklist

  1. Explain the answer without reading.
  2. Write one small example.
  3. Review platform or version differences in official documentation.

logoblog

No comments:

Post a Comment

Please do not enter any spam link in the comment box.