C Programming – 2-Mark Questions and Answers
1. What is C language?
C is a general-purpose, structured programming language developed by Dennis Ritchie at Bell
Labs in 1972. It is widely used for system programming and developing operating systems.
2. What are the features of C?
• Simple and efficient • Structured language • Supports low-level memory access • Rich library of
functions • Portable across platforms
3. What are keywords in C?
Keywords are reserved words in C that have predefined meanings and cannot be used as
identifiers. Example: int, float, if, return.
4. What is a variable?
A variable is a named memory location used to store data during program execution. Example: int
age = 20;
5. What is the syntax of if statement?
Syntax: if(condition) { // statements } Example: if(age > 18) { printf("Eligible"); }
6. What is a loop? Name its types.
A loop is used to execute a block of code repeatedly. Types: for loop, while loop, do-while loop.
7. What is an array?
An array is a collection of elements of the same data type stored in contiguous memory locations.
Example: int arr[5] = {1,2,3,4,5};
8. What is a function in C?
A function is a block of code that performs a specific task and can be reused. Example: int add(int
a, int b) { return a+b; }
9. Difference between call by value and call by reference?
• Call by value: copies actual value into function, changes do not affect original variable. • Call by
reference: passes address, changes affect original variable.
10. What is pointer in C?
A pointer is a variable that stores the memory address of another variable. Example: int *p, a=10;
p=&a;
11. What is structure in C?
A structure is a user-defined data type that groups different types of variables under a single name.
Example: struct Student {int id; char name[20];};
12. What is difference between structure and array?
• Array: stores elements of same type. • Structure: stores elements of different types under one
name.
13. What is recursion?
Recursion is the process where a function calls itself to solve smaller instances of a problem.
Example: factorial function.
14. What are storage classes in C?
• auto – default storage • static – retains value between calls • extern – global variable declaration •
register – stores in CPU register
15. What is difference between break and continue?
• break – exits the loop immediately. • continue – skips current iteration and continues next cycle of
loop.