MCQ Bank
What does the while statement in a loop structure signify?
- A) The end of the loop.
- B) The body of the loop.
- C) The condition for repeating the loop.
- D) The initialization of loop variables.
In the given example, what does the loop do? while (pH level > 4): add a drop of sulfuric acid
- A) Adds a drop of sulfuric acid only once.
- B) Adds a drop of sulfuric acid if the pH level is less than or equal to 4.
- C) Adds a drop of sulfuric acid regardless of the pH level.
- D) Adds a drop of sulfuric acid if the pH level is greater than 4.
What will be the output of the following pseudocode? marks = 60 if (marks>=50) Print(You have passed the examination) Else Print(You have failed the examination)
- A) You have failed the examination
- B) Both messages will be displayed
- C) No message will be displayed
- D) You have passed the examination
Loop, is executed in a repetitive fashion under the direction of some
- A) Under some background knowledge
- B) Sequence process
- C) Control process
- D) Halting process
What advantage does a loop structure provide over explicitly writing the body multiple times?
- A) It simplifies the structure of the algorithm.
- B) It increases the error-proneness of the algorithm.
- C) It reduces the flexibility of the algorithm.
- D) It allows for greater flexibility without knowing in advance how many iterations are needed.
What will be the output of the loop for the given example? int i=3; while(i<=5) { cout<<i; i=i+1; }
- A) 12345
- B) 333
- C) 345
- D) 54321
What were developed to convert mnemonic expressions into machine language instructions?
- A) Interpreters
- B) Programs
- C) Compilers
- D) Assemblers
In __________ paradigm, task of programmer is to develop a precise problem statement rather than designing an algorithm for solving the problem.
- A) Object-Oriented
- B) Imperative
- C) Declarative
- D) Functional
Control structure which iterates a set of instructions based on the provided condition, is called a ______________.
- A) Conditional statement
- B) Function
- C) Loop
- D) Class
Post test loop structure refer to?
- A) Test for termination is performed as well as the body is executed
- B) Test for termination is performed after the body is executed
- C) Test for termination is performed with the body is executed
- D) Test for termination is performed before the body is executed
Sequential search involves a circular form of repetition; the binary search executes each stage of the repetition as a subtask of the previous stage known as
- A) Transition
- B) Recursion
- C) Searching
- D) Decomposition
What does the modification step in loop control accomplish?
- A) Establishes a starting condition
- B) Moves the condition toward the termination condition
- C) Compares the current state to the termination condition
- D) Terminates the loop
Why is the initialization step important in loop control?
- A) It executes the loop body
- B) It establishes a starting condition that will be modified toward the termination condition
- C) It compares the current state to the termination condition
- D) It ensures the termination of the looping process
If we have to insertion sort on names Fred, Alex, Diana ,Byron ,Carol
One approach to sorting this list is to note that the sublist consisting of
- A) Sub list having 3 names
- B) Only carol
- C) Both fred and alex
- D) Only top name
In what case "Give Scholarship" statement will be executed in the following code? if (CGPA>=3.0) cout<<”Give Scholarship”; else cout<<”Sorry you do not qualify for the scholarship”;
- A) For CGPA value 2.9 or less
- B) Both statements will be executed in any case
- C) For any CGPA value above three
- D) CGPA is less than three
What is the purpose of an assignment statement in programming?
- A) To terminate the program
- B) To assign a value to a variable
- C) To declare variables
- D) To request input from the user
How many iterations are required to find 88 in the following array?
{5, 6, 77, 88, 99}
- A) 1
- B) 4
- C) 3
- D) 2
Which of the following is not a relational operator in C++?
- A) %=
- B) > =
- C) ! =
- D) = =
Which of the following is the correct syntax to initialize a 3-element integer array in C/C++?
- A) int arr[3] = {1,2,3}
- B) int arr(3) = {1,2,3}
- C) int arr(3) = (1,2,3);
- D) int arr[3] = (1,2,3)
What is the output of the following code?
int sum = 14;
if ( sum < 20 )
cout<<"Under ";
if ( sum > 20 )
cout<<"Over ";
cout<<"the limit.";
- A) Under
- B) Over the limit
- C) Over
- D) Under the limit