Q#1: What does the increment statement (third part of for statement) do in a for loop?
(A) Executes before the body of the loop
(B) Executes during the first iteration
(C) Executes after executing the body of the loop
(D) Executes only if the loop condition is false
Answer: (C) Executes after executing the body of the loop
Q#2: In the given for loop, why will the body not be executed even a single time?
(A) The initialization value is 5
(B) The loop condition is always false
(C) The loop increments counter before executing the body
(D) The loop increments counter after executing the body
Answer: (B) The loop condition is always false
Q#3: In the sample program for the table of 2, what is the condition in the for loop?
(A) counter < 10
(B) counter <= 10
(C) counter > 10
(D) counter >= 10
Answer: (B) counter <= 10
Q#4: What is the value of counter in the first iteration of the table of 2 program?
(A) 0
(B) 1
(C) 2
(D) 10
Answer: (B) 1
Q#5: Why does the program suggest using variables for constant values instead of explicit constant values?
(A) To make the code longer
(B) To avoid using variables
(C) To ease future changes to constant values
(D) To make the code more complex
Answer: (C) To ease future changes to constant values
Q#6: What does the increment operator ++ do in C?
(A) Adds 1 to the variable
(B) Subtracts 1 from the variable
(C) Multiplies the variable by 1
(D) Divides the variable by 1
Answer: (A) Adds 1 to the variable
Q#7: In post-increment, when is the value of the variable increased?
(A) Before using it in the expression
(B) After using it in the expression
(C) During the first iteration
(D) Before the loop body executes
Answer: (B) After using it in the expression
Q#8: What is the difference between pre-increment and post-increment operators?
(A) Pre-increment increases the value after using it; post-increment increases before using it
(B) Pre-increment increases the value before using it; post-increment increases after using it
(C) They are equivalent and can be used interchangeably
(D) Pre-increment is used in loops, post-increment is not
Answer: (B) Pre-increment increases the value before using it; post-increment increases after using it
Q#9: Which compound assignment operator is used for subtraction in C?
(A) +=
(B) -=
(C) *=
(D) /=
Answer: (B) -=
Q#10: What does the %= operator do in C?
(A) Adds the right operand to the left operand
(B) Subtracts the right operand from the left operand
(C) Multiplies the left operand by the right operand
(D) Computes the remainder when the left operand is divided by the right operand
Answer: (D) Computes the remainder when the left operand is divided by the right operand
Q#11: In the generic table program, what does the variable maxMultiplier control?
(A) The maximum value of the counter
(B) The minimum value of the counter
(C) The number of times the loop executes
(D) The value to be displayed in the table
Answer: (C) The number of times the loop executes
Q#12: What is the purpose of the decrement operator in C?
(A) Adds 1 to the variable
(B) Subtracts 1 from the variable
(C) Multiplies the variable by 1
(D) Divides the variable by 1
Answer: (B) Subtracts 1 from the variable
Q#13: When using post-decrement, when is the value of the variable decreased?
(A) Before using it in the expression
(B) After using it in the expression
(C) During the first iteration
(D) Before the loop body executes
Answer: (B) After using it in the expression
Q#14: How can a program be made more generic according to the paragraph?
(A) By using explicit constant values
(B) By avoiding variables
(C) By using variables for constant values
(D) By making the code more complex
Answer: (C) By using variables for constant values
Q#15: What is the purpose of the code that uses the << “2 x ” statement in the table program?
(A) To print the value of counter
(B) To print the multiplication symbol
(C) To display the result of the multiplication
(D) To create a new line
Answer: (B) To print the multiplication symbol
Q#16: What does the for loop in the table program terminate based on?
(A) Initialization value
(B) Loop condition
(C) Increment statement
(D) Decrement statement
Answer: (B) Loop condition
Q#17: In the given paragraph, what is suggested for a good programming style related to constant values?
(A) Use explicit constant values
(B) Use variables for constant values
(C) Avoid using variables
(D) Use any approach, it doesn’t matter
Answer: (B) Use variables for constant values
Q#18: In the sample program for the table of 2, what is the output after the first iteration?
(A) 2 x 0 = 0
(B) 2 x 1 = 2
(C) 2 x 2 = 4
(D) The loop terminates without output
Answer: (B) 2 x 1 = 2
Q#19: What does the << “\n” statement in the table program do?
(A) Adds a space
(B) Creates a new line
(C) Terminates the program
(D) Prints the multiplication symbol
Answer: (B) Creates a new line
Q#20: According to the paragraph, when does the body of the for loop execute in the table program?
(A) Before the increment statement
(B) After the increment statement
(C) Before the loop condition is checked
(D) After the loop condition is checked
Answer: (B) After the increment statement