C Programming Interview questions

 

1. Basic C Programming Concepts

  1. What are the main features of the C programming language?

  2. Explain the structure of a basic C program.

  3. What is the difference between a compiler and an interpreter?

  4. How do you declare and initialize variables in C?

  5. What is the use of the printf() and scanf() functions?

  6. What are keywords in C? List a few examples.

  7. Explain the difference between int, float, char, and double data types.

  8. What are constants? How do you define them?

  9. Explain the purpose of comments in C.

  10. How does C handle memory management?


🔢 2. Operators and Control Structures

  1. What is the difference between = and == in C?

  2. Explain the difference between logical (&&, ||, !) and bitwise operators (&, |, ^).

  3. How does the ternary operator (? :) work in C?

  4. What is operator precedence and associativity?

  5. Explain the difference between break, continue, and goto.

  6. How do if, else if, and switch statements differ?

  7. What is a loop? Describe for, while, and do-while loops.

  8. What is an infinite loop? How can you create one?

  9. Explain how to use a switch statement effectively.

  10. How does the sizeof() operator work in C?


🧮 3. Functions in C

  1. What is the syntax for declaring and defining a function?

  2. Explain the difference between call by value and call by reference.

  3. What is a recursive function? Provide an example.

  4. How do you use function pointers?

  5. What is the difference between void and other return types?

  6. What is the purpose of the main() function in C?

  7. Can a function return multiple values? How?

  8. What are inline functions? Are they supported in C?

  9. What is a function prototype?

  10. How do static functions differ from regular functions?


📊 4. Arrays and Strings

  1. How do you declare and initialize an array in C?

  2. What is the difference between one-dimensional and multi-dimensional arrays?

  3. How do you pass an array to a function?

  4. Explain the concept of an array of pointers.

  5. What are common string manipulation functions in C (e.g., strlen(), strcpy())?

  6. How do you compare two strings in C?

  7. What is the difference between character arrays and strings?

  8. How can you reverse a string in C?

  9. How do you dynamically allocate memory for an array?

  10. What are the limitations of arrays in C?


📌 5. Pointers and Memory Management

  1. What is a pointer? How do you declare and initialize one?

  2. Explain the difference between * and & in pointers.

  3. What are null pointers and void pointers?

  4. How does pointer arithmetic work in C?

  5. What is the purpose of malloc(), calloc(), realloc(), and free()?

  6. How do you create a pointer to a function?

  7. What happens if you access memory out of bounds using a pointer?

  8. How do you handle dangling pointers?

  9. What is the difference between stack and heap memory?

  10. How do you return a pointer from a function safely?


📂 6. Advanced Topics

  1. What is a structure? How do you declare and use one?

  2. How does a union differ from a structure?

  3. What are file handling functions in C (e.g., fopen(), fclose())?

  4. What is a preprocessor directive? Give examples.

  5. How do you use #define and typedef?

  6. What are enum and bit fields in C?

  7. What is the use of volatile and const keywords?

  8. What are memory leaks, and how do you prevent them?

  9. How do you pass command-line arguments to a C program?

  10. What are some common segmentation faults and how to debug them?

Featured Posts

Software Architect Interview Preparation Plan

  ✅ Software Architect Interview Preparation Plan (14 Weeks) 📅 Phase 1: Core Foundations (Weeks 1-3) 1. Software Design Principles Master...

Popular Posts