C and C++ interview questions

C and C++ interview questions

Basic C Questions

  1. What is C language?

  2. What are the features of C?

  3. What is a compiler?

  4. What is the difference between compiler and interpreter?

  5. What is a variable in C?

  6. What is a data type? Give some examples.

  7. What are keywords in C?

  8. What is the difference between int, float, and char?

  9. How do you write a simple "Hello World" program in C?

  10. What is the use of main() function?

 

C Operators & Control Statements

  1. What are arithmetic operators in C?

  2. What is the difference between = and ==?

  3. What are logical operators?

  4. What is the use of if-else?

  5. What is the difference between while and do-while loop?

  6. What is a switch statement?

  7. What is a break statement?

  8. What is a continue statement?

  9. What is a ternary operator?

  10. What is the use of goto in C?

 

Functions in C

  1. What is a function?

  2. What is the difference between call by value and call by reference?

  3. Can we return multiple values from a function?

  4. What is recursion?

  5. What is the scope of a variable?

  6. What is a static variable?

  7. What is an inline function?

  8. What is the difference between void and int return type?

  9. What is the use of return statement?

  10. What is function overloading? Is it supported in C?

 

Arrays, Strings, and Pointers in C

  1. What is an array?

  2. How to declare and use a 2D array?

  3. What is a string in C?

  4. How are strings stored in memory?

  5. What is a pointer?

  6. How to declare a pointer?

  7. What is the use of * and & in pointers?

  8. What is a NULL pointer?

  9. What is a dangling pointer?

  10. How can you use pointers with arrays?

 

Structures and Unions

  1. What is a structure in C?

  2. How is a structure different from an array?

  3. What is a union?

  4. What is the difference between structure and union?

  5. Can we use pointers with structures?

  6. Can we pass a structure to a function?

  7. What is typedef?

  8. Can we nest structures?

  9. What is padding in structure?

  10. What is the size of an empty structure?

 

Memory Management

  1. What is dynamic memory allocation?

  2. What is the use of malloc()?

  3. What is the use of calloc()?

  4. What is realloc()?

  5. What is free()?

  6. What are memory leaks?

  7. How can you avoid memory leaks?

  8. What is stack vs heap memory?

  9. What happens if you free a NULL pointer?

  10. What is the difference between static and dynamic memory?

 

File Handling in C

  1. How to open a file in C?

  2. What is the use of fopen()?

  3. How to read and write in a file?

  4. What is fprintf() and fscanf()?

  5. What is the difference between fgets() and gets()?

  6. How to close a file?

  7. What is the difference between text and binary files?

  8. What is fseek() used for?

  9. How to append data to a file?

  10. What are file modes in fopen()?

 

Basic C++ Questions

  1. What is C++?

  2. What are the main features of C++?

  3. What is object-oriented programming (OOP)?

  4. What is a class in C++?

  5. What is an object?

  6. What is encapsulation?

  7. What is inheritance?

  8. What is polymorphism?

  9. What is abstraction?

  10. What is constructor and destructor?

 

Advanced C++ Concepts

  1. What is function overloading in C++?

  2. What is operator overloading?

  3. What is the difference between method overloading and overriding?

  4. What is a virtual function?

  5. What is a pure virtual function?

  6. What is an abstract class?

  7. What is the use of this pointer?

  8. What is the difference between new and malloc()?

  9. What is multiple inheritance?

  10. What is a friend function?

 

General & Miscellaneous

  1. What is the difference between C and C++?

  2. What is a header file?

  3. What is the difference between #include <file> and #include "file"?

  4. What is a segmentation fault?

  5. What is the difference between compile time and runtime?

  6. What is a linker and loader?

  7. What is the use of preprocessor directives like #define?

  8. What is macro?

  9. What is the use of const?

  10. What are best practices in C/C++ programming?

Share: