2.1.1 - Introduction to C.
1. What is a primary feature of the C programming language?
- A) High-level language with no control over hardware
- B) Machine-dependent and complex
- C) General-purpose and flexible
- D) Designed exclusively for web development
Correct Answer: C) General-purpose and flexible
2. C is often referred to as a "middle-level" language because it combines elements of:
- A) High-level language and assembly language
- B) High-level language and low-level language
- C) Assembly language and machine language
- D) High-level language and scripting language
Correct Answer: A) High-level language and assembly language
3. Which of the following is NOT a feature of the C programming language?
- A) Portability
- B) Complex syntax
- C) Fast and efficient
- D) Structure-oriented programming
Correct Answer: B) Complex syntax
4. In C programming, which file type contains the source code of the program?
- A) Header file
- B) Object file
- C) Source file
- D) Executable file
Correct Answer: C) Source file
5. What is the role of a header file in C programming?
- A) Contains the final executable code
- B) Contains macro definitions and function declarations
- C) Contains the compiled machine code
- D) Used for linking the program to the operating system
Correct Answer: B) Contains macro definitions and function declarations
6. Which file extension is used for an object file in C programming?
- A) .c
- B) .h
- C) .o
- D) .exe
Correct Answer: C) .o
7. What does an executable file in C programming represent?
- A) The source code before compilation
- B) The linked and compiled binary code
- C) The header information
- D) The object code in a relocatable format
Correct Answer: B) The linked and compiled binary code
8. Which step comes immediately after writing a C program in a text editor?
- A) Execution
- B) Linking
- C) Compilation
- D) Debugging
Correct Answer: C) Compilation
9. What is the purpose of flowcharts in programming?
- A) To compile code into machine language
- B) To provide a pictorial representation of algorithms
- C) To debug and optimize code
- D) To execute the final program
Correct Answer: B) To provide a pictorial representation of algorithms
10. What is NOT one of the essential features of an algorithm?
- A) Definiteness
- B) Effectiveness
- C) Complexity
- D) Finiteness
Correct Answer: C) Complexity
11. Which year was the first version of C released?
- A) 1969
- B) 1972
- C) 1978
- D) 1983
Correct Answer: B) 1972
12. What was the name of the first book published on C programming in 1978?
- A) "The C Programming Language"
- B) "Introduction to C Programming"
- C) "C for Beginners"
- D) "Programming with C"
Correct Answer: A) "The C Programming Language"
13. Which organization standardized C in 1983?
- A) ISO
- B) ANSI
- C) IEEE
- D) W3C
Correct Answer: B) ANSI
14. In which year were new features like type checking and memory management included in the ISO C standard?
- A) 1978
- B) 1983
- C) 1999
- D) 2011
Correct Answer: C) 1999
15. What is the main advantage of C being a "platform-independent" language?
- A) It does not require any compilation
- B) It can run on any hardware and operating system
- C) It is exclusively used for system programming
- D) It does not need any lihraries
Correct Answer: B) It can run on any hardware and operating system
2.1.2 - Basic Structure of C Programming.
16. What is the purpose of the documentation section in a C program?
- A) To execute the program
- B) To include comments and descriptions about the program
- C) To declare variables
- D) To perform input/output operations
Correct Answer: B) To include comments and descriptions about the program
17. Which symbol is used to start a multi-line comment in C?
Correct Answer: B) /*
18. What does the #include statement do in a C program?
- A) It defines a constant
- B) It includes the standard input-output lihrary
- C) It starts the main function
- D) It declares a variable
Correct Answer: B) It includes the standard input-output lihrary
19. What is a header file in C?
- A) A file that contains main functions
- B) A file with function declarations and macros
- C) A file that executes the program
- D) A file that contains global variables
Correct Answer: B) A file with function declarations and macros
20. What does the #define directive do in a C program?
- A) It declares a global variable
- B) It defines a macro or constant value
- C) It includes a header file
- D) It starts the main function
Correct Answer: B) It defines a macro or constant value
21. Which part of the C program is executed first?
- A) Global declarations
- B) Documentation section
- C) Main function
- D) Return statement
Correct Answer: C) Main function
22. In C, what are global variables?
- A) Variables declared inside a function
- B) Variables declared outside all functions and accessible throughout the program
- C) Variables declared only in the main function
- D) Variables declared using the #define directive
Correct Answer: B) Variables declared outside all functions and accessible throughout the program
23. What is the correct way to start the main function in C?
- A) void main()
- B) start main()
- C) main()
- D) int main()
Correct Answer: D) int main()
24. Why are variables declared at the beginning of a function in C?
- A) To make the program run faster
- B) To ensure variables are declared before they are used
- C) To allocate memory at the end of the program
- D) To include lihraries
Correct Answer: B) To ensure variables are declared before they are used
25. What is the body of a function in C?
- A) The section where variables are declared
- B) The section where header files are included
- C) The section where the main function is defined
- D) The section where the actual operations and logic of the function are implemented
Correct Answer: D) The section where the actual operations and logic of the function are implemented
26. Which function is used to print output in C?
- A) scanf()
- B) output()
- C) printf()
- D) print()
Correct Answer: C) printf()
27. What does the return statement in C do?
- A) It starts a loop
- B) It terminates the program
- C) It returns a value from a function
- D) It includes a header file
Correct Answer: C) It returns a value from a function
28. Which of the following is NOT a standard C header file?
- A) math.h
- B) stdlib.h
- C) stdvec.h
- D) string.h
Correct Answer: C) stdvec.h
29. What is the correct syntax for defining a constant named PI with a value of 3.14 in C?
- A) #define PI = 3.14;
- B) #define PI 3.14
- C) const PI = 3.14;
- D) constant PI = 3.14;
Correct Answer: B) #define PI 3.14
30. In a C program, what does int a = 100; do?
- A) It defines a header file
- B) It declares a function
- C) It declares an integer variable a and initializes it to 100
- D) It declares a macro
Correct Answer: C) It declares an integer variable a and initializes it to 100
31. Which of the following statements about the main function is true?
- A) Every C program must have a main function
- B) The main function is optional in a C program
- C) The main function can only have one line of code
- D) The main function must always return an integer value
Correct Answer: A) Every C program must have a main function
32. What is the use of the printf() function?
- A) To read input from the user
- B) To display output to the user
- C) To declare a variable
- D) To include header files
Correct Answer: B) To display output to the user
33. Which operator is used to access the address of a variable in C?
Correct Answer: B) &
34. Which of the following is a correct way to end a C program?
- A) exit()
- B) return 0;
- C) stop;
- D) hreak;
Correct Answer: B) return 0;
35. What is the result of the expression 5 + 3 * 2 in C?
Correct Answer: B) 11