1. What is C Programming?
C is a structured, procedural, and general-purpose programming language developed by Dennis Ritchie in 1972 at Bell Labs. It is widely used for system programming, operating systems, embedded systems, and application development. C provides low-level memory access using pointers and high-level constructs like functions and control statements. Because of this combination, it is called a middle-level language.
2. What are the key features of C language?
- Simple: Easy syntax and structured format.
- Portable: Programs written in C can run on different machines with little modification.
- Efficient: Close to hardware, fast execution.
- Rich Library: Many built-in functions.
- Pointer Support: Direct memory manipulation.
- Structured Programming: Divides program into functions.
3. Explain the structure of a C program.
A typical C program contains:
- Documentation Section (comments)
- Link Section (#include header files)
- Definition Section (#define constants)
- Global Declaration Section
- Main() Function (entry point)
- User-defined Functions
The execution of every C program starts from the main() function.
4. What is a variable?
A variable is a named memory location used to store data. Each variable has a data type which defines the type of value it can hold. Example: int age = 20; Here, “age” is a variable storing integer value 20.
5. What are data types in C?
Data types define the size and type of data stored in a variable.
- Basic: int, char, float, double
- Derived: array, pointer
- User-defined: struct, union, enum
6. Difference between int, float and double?
int: Stores whole numbers (4 bytes).
float: Stores decimal values (single precision, 4 bytes).
double: Stores decimal values with higher precision (8 bytes).
7. What is a constant?
A constant is a fixed value that does not change during program execution. It can be defined using const keyword or #define preprocessor directive.
8. What are keywords?
Keywords are reserved words in C that have predefined meanings and cannot be used as variable names. Examples: int, return, if, while, break.
9. Explain operators in C.
Operators perform operations on variables and values:
- Arithmetic: +, -, *, /, %
- Relational: ==, !=, >, <, >=, <=
- Logical: &&, ||, !
- Assignment: =, +=, -=
- Bitwise: &, |, ^, ~
10. What is the difference between = and ==?
= assigns value to a variable. Example: a = 5.
== compares two values. Example: if(a == 5).
11. What is type casting?
Type casting converts one data type into another manually. Example: int a = 5; float b = (float)a; It is useful to avoid data loss or control precision.
12. Explain conditional statements.
Conditional statements control decision-making in programs.
- if – executes block if condition is true.
- if-else – chooses between two blocks.
- switch – selects one case among many.
13. What is a loop?
A loop executes a block of code repeatedly until a condition becomes false. It reduces code repetition.
14. Types of loops in C?
- for loop: Used when number of iterations is known.
- while loop: Condition checked before execution.
- do-while loop: Executes at least once.
15. Difference between while and do-while?
In while loop, condition is checked first. If false, loop will not execute. In do-while, loop executes at least once before checking condition.
16. What is break statement?
break terminates loop or switch immediately and transfers control outside.
17. What is continue statement?
continue skips current iteration and proceeds to next iteration of loop.
18. What is an array?
An array is a collection of elements of same data type stored in contiguous memory locations. It is accessed using index starting from 0.
19. What is a string in C?
A string is an array of characters terminated by null character ‘\0’. Example: char name[] = “John”;
20. What is a function?
A function is a reusable block of code designed to perform a specific task. It improves modularity and readability.
21. What is recursion?
Recursion is when a function calls itself to solve smaller sub-problems. It must have a base condition to stop execution.
22. What is a pointer?
A pointer is a variable that stores memory address of another variable. It allows direct memory access and is powerful feature of C.
23. What is NULL pointer?
A NULL pointer does not point to any valid memory location. It is good practice to initialize pointers with NULL.
24. Explain pointer arithmetic.
Pointer arithmetic allows incrementing, decrementing, or subtracting pointers. It moves pointer according to size of data type.
25. What is dynamic memory allocation?
Dynamic memory allocation is allocating memory at runtime using malloc(), calloc(), realloc(), and free(). It helps manage memory efficiently.
26. Difference between malloc() and calloc()?
malloc() allocates memory but does not initialize it. calloc() allocates and initializes memory to zero.
27. What is a structure?
A structure groups different types of variables under one name. Example: storing student details (name, roll, marks).
28. What is union?
Union allows storing different data types in same memory location. Only one member can hold value at a time.
29. Difference between structure and union?
Structure allocates separate memory for each member. Union shares same memory for all members.
30. What is typedef?
typedef creates a new name for existing data type for better readability.
31. What is enum?
Enum defines a set of named integer constants. Example: enum day {Mon, Tue, Wed};
32. What is file handling?
File handling allows storing data permanently in files using fopen(), fclose(), fprintf(), fscanf(), fread(), fwrite().
33. What is preprocessor?
Preprocessor executes before compilation and handles directives like #include and #define.
34. What is macro?
A macro is a symbolic constant defined using #define. It replaces value before compilation.
35. What is header file?
Header files contain function declarations and macros. Example: stdio.h, stdlib.h.
36. What is command line argument?
Arguments passed to main(int argc, char *argv[]) from command line.
37. What is segmentation fault?
Segmentation fault occurs when program accesses invalid memory location.
38. What is dangling pointer?
A pointer that points to freed or deleted memory location.
39. What is static variable?
Static variable retains its value between multiple function calls.
40. What is extern keyword?
extern allows access of global variable in another file.
41. What is volatile keyword?
volatile tells compiler that variable value may change unexpectedly.
42. What is memory leak?
Memory leak happens when allocated memory is not freed using free().
43. What is stack memory?
Stack memory stores local variables and function calls. It is automatically managed.
44. What is heap memory?
Heap memory is dynamically allocated memory managed manually by programmer.
45. What is call by value?
Call by value passes copy of variable. Original value does not change.
46. What is call by reference?
Call by reference passes address of variable. Changes affect original variable.
47. What is infinite loop?
A loop that never terminates because condition always remains true.
48. What is exit() function?
exit() terminates program immediately.
49. What is difference between local and global variable?
Local variable declared inside function. Global variable declared outside function and accessible throughout program.
50. Why is C important for interviews?
C builds strong foundation in memory management, pointers, and problem-solving. Many modern languages are based on C concepts, so understanding C helps in mastering other languages.
Interview Preparation Strategy
- Practice pointer-based programs.
- Understand memory management clearly.
- Revise arrays, strings, and structures.
- Practice writing logic on paper.
- Explain answers confidently with examples.
📢 Join Our WhatsApp Channel
💼 Get Daily IT Job Updates, Interview Preparation Tips & Instant Alerts directly on WhatsApp.
👉 Join WhatsApp Now📢 Join Our Telegram Channel
💼 Get Daily IT Job Updates, Interview Tips & Exclusive Alerts directly on Telegram!
👉 Join Telegram