C Home
C Introduction
C Variables
C Data Types
C Operators
C Decision Making
C Loops
C Functions
C Arrays
C Strings
C Pointers
C Structures
C Unions
C File Handling
C Dynamic Memory Allocation
C Storage Classes
C Header Files
C Preprocessor Directives
C Typedef
C Enumeration (enum)
C Recursion
C Bitwise Operators
C Command Line Arguments
C Interview Questions
C Programming MCQs
C Programs
C Interview Questions
Introduction
Preparing for a C programming interview requires a good understanding of fundamental concepts, programming logic, memory management, pointers, functions, arrays, structures, and file handling.
This section contains some of the most commonly asked C programming interview questions with simple and easy-to-understand answers.
These questions are useful for campus placements, technical interviews, viva examinations, and competitive programming preparation.
Basic C Interview Questions
1. What is C Programming?
C is a general-purpose, procedural programming language developed by Dennis Ritchie in 1972 at Bell Labs. It is widely used for system programming, embedded systems, and application development.
2. What are the basic data types in C?
The basic data types in C are:
• int
• char
• float
• double
These data types are used to store different kinds of values.
3. What is the difference between a compiler and an interpreter?
A compiler translates the entire source code into machine code before execution, whereas an interpreter translates and executes the program line by line.
4. What is a variable in C?
A variable is a named memory location used to store data. Its value can change during program execution.
5. What is a constant in C?
A constant is a fixed value that cannot be changed during program execution. Constants can be numeric, character, or string values.
6. What is the difference between local and global variables?
A local variable is declared inside a function and can only be accessed within that function. A global variable is declared outside all functions and can be accessed throughout the program.
7. What is a function in C?
A function is a block of code that performs a specific task. It helps reduce code duplication and improves program organization.
8. What is recursion?
Recursion is a programming technique where a function calls itself until a base condition is met.
9. What are pointers in C?
A pointer is a variable that stores the memory address of another variable. Pointers are widely used in dynamic memory allocation and data structures.
10. What is the difference between Structure and Union?
In a structure, each member has its own memory location. In a union, all members share the same memory location, so only one member can store a valid value at a time.
11. What is an array in C?
An array is a collection of elements of the same data type stored in contiguous memory locations. Each element is accessed using an index.
12. What is a string in C?
A string is a sequence of characters terminated by the null character (‘\0’). Strings are stored in character arrays.
13. What is a header file in C?
A header file contains function declarations, macros, constants, and other definitions that can be shared across multiple C source files.
14. What is the purpose of the main() function?
The main() function is the entry point of every C program. Program execution begins from the main() function.
15. What are storage classes in C?
Storage classes define the scope, lifetime, and visibility of variables. The four storage classes are auto, register, static, and extern.
16. What is dynamic memory allocation?
Dynamic memory allocation is the process of allocating memory during program execution using functions such as malloc(), calloc(), realloc(), and free().
17. What is a null pointer?
A null pointer is a pointer that does not point to any valid memory location. It is usually assigned the value NULL.
18. What is a file pointer?
A file pointer is a pointer of type FILE that is used to access and manage files during file handling operations.
19. What is the difference between malloc() and calloc()?
malloc() allocates memory without initializing it, whereas calloc() allocates memory and initializes all bytes to zero.
20. What is the purpose of the break statement?
The break statement immediately terminates a loop or switch statement and transfers control to the next statement after it.
21. What is the continue statement in C?
The continue statement skips the remaining statements in the current loop iteration and moves to the next iteration of the loop.
22. What is the difference between while and do-while loops?
The while loop checks the condition before executing the loop body, whereas the do-while loop executes the loop body once before checking the condition.
23. What is the sizeof() operator?
The sizeof operator returns the size of a data type or variable in bytes. It is commonly used for memory allocation and array size calculations.
24. What is a dangling pointer?
A dangling pointer is a pointer that points to a memory location that has already been freed or is no longer valid.
25. What is a macro in C?
A macro is a named piece of code created using the #define directive. It is replaced by the preprocessor before compilation.
26. What is the difference between call by value and call by reference?
In call by value, a copy of the variable is passed to the function, so changes do not affect the original variable. In call by reference, the memory address is passed using pointers, so changes affect the original variable.
27. What is an infinite loop?
An infinite loop is a loop that never terminates because its condition always remains true or no terminating condition is provided.
28. What is the difference between ++i and i++?
++i is the pre-increment operator, which increments the value before it is used. i++ is the post-increment operator, which uses the current value first and increments it afterward.
29. What is a segmentation fault?
A segmentation fault is a runtime error that occurs when a program tries to access memory that it is not allowed to access.
30. Why is C called a middle-level programming language?
C is called a middle-level programming language because it supports both low-level features, such as memory manipulation using pointers, and high-level programming features, such as functions and structured programming.
Top 10 Frequently Asked C Interview Programs
The following programs are frequently asked in technical interviews, practical examinations, and campus placements.
• Factorial Program
• Fibonacci Series
• Prime Number
• Palindrome Number
• Armstrong Number
• Reverse a Number
• Swap Two Numbers
• Matrix Addition
• String Reverse
• Sorting an Array
Interview Tips
• Understand C fundamentals before learning advanced concepts.
• Practice writing programs without copying code.
• Learn pointers and memory management thoroughly.
• Revise loops, arrays, strings, and functions regularly.
• Be confident while explaining your program logic.
• Practice debugging common programming errors.
• Prepare both theory questions and programming questions.
Key Points
• C interviews include both theory and programming questions.
• Strong fundamentals improve interview performance.
• Practice common programs regularly.
• Understand pointers, arrays, strings, and functions.
• Revise memory management and file handling.
• Focus on writing clean and efficient code.
• Confidence and logical thinking are important during interviews.
