MCQ Bank
What does a control statement do in a program?
- A) Alters the execution sequence of program
- B) Performs arithmetic operations
- C) Prints output to the console
- D) Declares variables
When applied to a list with n entries, the sequential search algorithm will interrogate an average of ------ entries
- A) 2n
- B) N/2
- C) N*n
- D) N
Which term is commonly used for a loop where the termination test is performed before the body is executed?
- A) Preliminary loop
- B) Precondition loop
- C) Prerequisite loop
- D) Pretest loop
Which programming language was developed for scientific and engineering applications?
- A) Assembly Language
- B) COBOL
- C) FORTRAN
- D) Machine language
In the provided pseudo-code, what is the role of the "Current" variable? def FindMax(): max = first number in the list Current = second number in the list While (elements in the list exist) If (max<current) max=current Current = next value in the list
- A) It indicates the position of the current element in the list
- B) It represents the minimum value in the list
- C) It holds the maximum value in the list
- D) It stores the current value being compared
The control of a loop consists of the __________ activities.
- A) Three
- B) Two
- C) Four
- D) Five
What is the significance of the statement "f = f * i" in each iteration of the loop in the given pseudocode? f = 1 i=1; While (i<=n) f=f*i; i=i+1;
- A) It subtracts the loop counter "i" from the current value of "f"
- B) It has no impact in the loop
- C) It multiplies the current value of "f" by the loop counter "i"
- D) It resets the value of "f" to 1
Which of the following case does not exist in complexity theory?
- A) Null case
- B) Best case
- C) Worst case
- D) Average case
What is the ultimate goal when sorting a list within itself using the insertion sort algorithm?
- A) Shuffling entries
- B) Clearing off space
- C) Efficient use of storage space
- D) Efficient use of time to sort a list in quick time
Which loop structure refers as a pretest loop?
- A) Do while
- B) For each
- C) For
- D) While
Let a unsorted list Fred, Alex, Diana ,Byron ,Carol
Which one will be sorted at last
- A) Carol
- B) Fred
- C) Alex
- D) Diana
What condition triggers the termination of the sequential search algorithm as a failure on an ordered list of names?
- A) Equality of TargetValue and TestEntry
- B) TestEntry is smaller than TargetValue
- C) List is empty
- D) Reaching a name greater than the target name
How many times will the loop in the example below execute? int i=2; while(i<=5) { cout<<i; i=i+1; }
- A) 5 times
- B) 3 times
- C) 4 times
- D) 6 times
Float CGPA=3.5;
If (CGPA>=3.0)
Cout<<”Give Scholarship”;
Else
Cout<<”Sorry you do not qualify for the scholarship”;
It will show
- A) Good
- B) Display none
- C) Give Scholarship
- D) Sorry you do not qualify for the scholarship
In the context of the insertion sort algorithm, what is the restriction imposed on sorting a list?
- A) Make a tree of the list to sort entries
- B) Create a copy of the list to sort items one by one into the new list
- C) Sort using the same storage space without extra memory space
- D) Insertion sort can only be used on the list containing numeric values
What will be the output of following pseudo code?
def FindFactorial():
fact = 2
i=1;
While (i<=7)
fact=fact*i;
i=i+1;
print(fact)
- A) 120
- B) 980
- C) 10080
- D) 5040
How many relational operator are offered by C++?
- A) 4
- B) 2
- C) 6
- D) 8
Which of the following is the correct syntax for conditional statement?
- A) If (condition)
- B) If (condition Statement A Else Statement B.
- C) If condition) Statement A Else Statement B.
- D) If (condition) Statement A Else Statement B.
What is the output of the following code?
int sum =7;
if ( sum >= 20 )
cout<<"You win ";
if ( sum < 20 )
cout<<"You lose ";
cout<<"the prize.";
- A) You lose
- B) You lose the prize.
- C) You win the prize.
- D) You win
A program logic written in an ordinary language illustrating a structure similar to computer instructions is known as…….
- A) Pseudo codes
- B) Programs
- C) Flowcharts
- D) Algorithms