Introduction to Programming MCQs with Answers
Practice important Introduction to Programming MCQs with answers and explanations.
Multiple Choice Questions
Q381: Which of the following is correct about function calling by reference?
- A: The actual value is passed to the function
- B: The function receives a copy of the value
- C: The function receives the address of the value
- D: The function receives a new variable
View Answer
C
Q382: What is the primary use of pointers in C/C++?
- A: To store the memory address of a variable
- B: To store large numbers
- C: To perform arithmetic operations
- D: To access static variables
View Answer
A
Q383: In C/C++, what will be the result of the expression a = b inside an if statement?
- A: The code block will always execute
- B: The assignment will fail
- C: The if condition will always be false
- D: The if condition will always be true
View Answer
A
Q384: What is the role of the else block in an if-else statement?
- A: It is executed if the condition in the if statement is true
- B: It is executed if the condition in the if statement is false
- C: It is executed if the condition in the if statement is true or false
- D: It is optional and can be omitted
View Answer
B
Q385: How are multi-dimensional arrays stored in C/C++?
- A: In row-major order
- B: In column-major order
- C: In random order
- D: In any specified order
View Answer
A
Q386: What does the tellg function do in file handling?
- A: It moves the file pointer
- B: It provides the current position in the file
- C: It opens a file
- D: It writes to the file
View Answer
B
Q387: Which loop construct ensures that the loop body is executed at least once?
- A: while loop
- B: for loop
- C: do-while loop
- D: foreach loop
View Answer
C
Q388: What does the preprocessor in C do before compilation?
- A: Optimizes the code
- B: Enhances the code
- C: Replaces functions
- D: Creates a new source code file
View Answer
B
Q389: What is the purpose of the #include directive in C?
- A: To add comments to the code
- B: To include header files
- C: To define constants
- D: To replace variables
View Answer
B
Q390: How does the preprocessor treat the file included using #include<somefile>?
- A: Replaces it with the content of the file
- B: Optimizes it
- C: Compiles it separately
- D: Ignores it
View Answer
A