- What is C?
- A) A high-level programming language
- B) A low-level programming language
- C) A scripting language
- D) A markup language
- What is the purpose of a header file in C?
- A) To declare functions and variables
- B) To define functions and variables
- C) To declare and define functions and variables
- D) None of the above
- Which of the following is not a basic data type in C?
- A) int
- B) float
- C) double
- D) string
- What is the syntax for declaring an integer variable in C?
- A) var x = 5;
- B) int x = 5;
- C) x = 5;
- D) integer x = 5;
- What is the output of the following code?
#include <stdio.h> int main() { printf("%d", sizeof(char)); return 0; }
- A) 1
- B) 2
- C) 4
- D) 8
- What is the purpose of the
ifstatement in C?- A) To loop through a block of code
- B) To execute a block of code if a condition is true
- C) To execute a block of code if a condition is false
- D) To define a function
- What is a function in C?
- A) A block of code that performs a specific task
- B) A variable that stores a value
- C) A type of loop
- D) A conditional statement
- What is the purpose of the
returnstatement in C?- A) To terminate the program
- B) To exit a loop
- C) To return a value from a function
- D) None of the above
- What is the syntax for a
forloop in C?- A) for (int i = 0; i < 10; i++)
- B) for (i = 0; i < 10; i++)
- C) for i = 0 to 10
- D) for (int i = 0; i < 10)
- What is the purpose of the
breakstatement in C?- A) To exit a loop
- B) To skip to the next iteration of a loop
- C) To return a value from a function
- D) None of the above
- What is the purpose of the
continuestatement in C?- A) To exit a loop
- B) To skip to the next iteration of a loop
- C) To return a value from a function
- D) None of the above
- What is the purpose of the
switchstatement in C?- A) To define a function
- B) To loop through a block of code
- C) To execute a block of code based on the value of an expression
- D) None of the above
- What is the syntax for a
do-whileloop in C?- A) do (i = 0; i < 10; i++)
- B) do while (i < 10)
- C) while (i < 10) do
- D) do { /* code */ } while (i < 10)
- What is the purpose of the
typedefkeyword in C?- A) To define a new data type
- B) To declare a variable
- C) To define a function
- D) None of the above
- What is a pointer in C?
- A) A variable that stores the address of another variable
- B) A type of loop
- C) A conditional statement
- D) None of the above
- What is the purpose of the
malloc()function in C?- A) To allocate memory dynamically
- B) To free allocated memory
- C) To copy a string
- D) None of the above
- What is the purpose of the
fgets()function in C?- A) To read a line of text from a file
- B) To write a line of text to a file
- C) To copy a string
- D) None of the above
- What is the purpose of the
fopen()function in C?- A) To open a file for reading
- B) To open a file for writing
- C) To open a file for both reading and writing
- D) All of the above
- What is the purpose of the
fclose()function in C?- A) To close a file
- B) To open a file
- C) To read data from a file
- D) None of the above
- What is the purpose of the
feof()function in C?- A) To check if the end of a file has been reached
- B) To check if a file exists
- C) To check if a file is open
- D) None of the above
Answers:
1. A
2. A
3. D
4. B
5. A
6. B
7. A
8. C
9. A
10. A
11. B
12. C
13. D
14. A
15. A
16. A
17. A
18. D
19. A
20. A