1. What is C?
A high-level programming language known for its efficiency and control over system resources.
2. What is a pointer?
A variable that stores the memory address of another variable.
3. What is the difference between ++i and i++?
++i increments i before its value is used; i++ increments after its value is used.
4. What is a function?
A block of code that performs a specific task and can be reused.
5. What is the difference between call by value and call by reference?
Call by value passes a copy of the variable; call by reference passes the variable's address.
6. What are arrays?
A collection of elements of the same data type stored in contiguous memory locations.
7. What is a structure?
A user-defined data type that groups related variables of different data types.
8. What is a union?
Similar to a structure but only one member can hold a value at a time.
9. What is a string in C?
An array of characters terminated by a null character (\0).
10. What is the purpose of #include?
It is a preprocessor directive that includes header files in a program.
11. What is dynamic memory allocation?
Allocating memory at runtime using functions like malloc(), calloc(), and free().
12. What is a memory leak?
When allocated memory is not deallocated, leading to wasted resources.
13. What is the difference between malloc() and calloc()
malloc() allocates uninitialized memory; calloc() allocates zero-initialized memory.
14. What is the purpose of free()
It deallocates previously allocated memory.
15. What is a loop?
A control structure that repeats a block of code multiple times.
16. What are the types of loops in C?
for, while, and do-while loops.
17. What is an if statement?
A conditional statement that executes a block of code if a specified condition is true.
18. What is a switch statement?
A multi-way branch statement that executes code based on the value of a variable.
19. What is a break statement?
It exits the nearest enclosing loop or switch statement.
20. What are operators?
Symbols that perform operations on variables and values.
21. What is the difference between == and =?
== is a comparison operator; = is an assignment operator.
22. What are logical operators?
Operators that return true or false based on logical expressions (&&, ||, !).
23. What is the modulus operator?
The % operator returns the remainder of a division operation.
24. What is the ternary operator?
A shorthand for if-else, written as condition ? expr1 : expr2
25. What is recursion?
A function that calls itself to solve a problem.
26. What is a header file?
A file containing function declarations and macro definitions, usually with a .h extension.
27. What is the main() function?
The entry point of a C program where execution begins.
28. What is a macro?
A preprocessor directive that defines a shorthand for a longer code snippet.
29. What is a static variable?
A variable that retains its value between function calls.
30. What is file handling in C?
The process of reading from and writing to files using C functions.
31. What are the modes of file operation?
r (read), w (write), a (append), r+ (read and write).
32. What is the purpose of fopen()
To open a file and return a file pointer.
33. What is the purpose of fclose()
To close an open file.
34. What are fprintf() and fscanf()
Functions used for formatted writing to and reading from files.
35. What is the purpose of typedef?
To create an alias for a data type.
36. What is the difference between struct and union?
struct can store multiple data types, while union can store only one at a time.
37. What is the volatile keyword?
A keyword that tells the compiler that a variable may be changed by something outside the control of the code.
38. What is the difference between fgets() and gets()
fgets() is safer and can limit input size; gets() can lead to buffer overflow.
39. What is a dangling pointer?
A pointer that points to a memory location that has been deallocated.
40. What is the difference between a local and global variable?
A local variable is declared within a function and cannot be accessed outside; a global variable is accessible throughout the program.
41. What are the valid identifiers in C?
Identifiers must begin with a letter or underscore and can contain letters, digits, and underscores.
42. What is a function prototype?
A declaration of a function that specifies its name, return type, and parameters without defining its body.
43. What is inline function?
A function that is expanded in line when called, used for small, frequently called functions.
44. What is a preprocessor?
A tool that processes source code before compilation, handling directives like #include and #define.
45. What are comments in C?
Text in the code ignored by the compiler, used for explanations. Syntax: // for single-line, /*...*/ for multi-line.
46. What is the purpose of const keyword?
To define a constant variable whose value cannot be changed.
47. What is modularization?
Dividing a program into smaller modules to improve clarity and manageability.
48. What are best practices for writing C code?
Use comments, follow naming conventions, avoid global variables, and modularize code.
49. What is the difference between struct and enum?
struct groups variables of different types; enum defines a set of named integer constants.
50. What is type casting?
Converting a variable from one data type to another.
51. What is a null pointer?
A pointer that does not point to any memory location or object.
52. What is a default argument?
A value that a function parameter assumes if no argument is passed.
53. What is the purpose of main() returning an integer?
To indicate the success or failure of the program to the operating system.
© TeachMind G, All Right Reserved || Designed and Maintained by BTPL.