MCQ Bank
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
In the context of program development, what is the goal of finding a general algorithm?
- A) To solve a particular instance of a problem.
- B) To develop an algorithm that can solve all instances of a problem.
- C) To find a specific solution for each instance.
- D) To solve a specific problem without decomposition.
What is the expected outcome of "f" for the given pseudo-code if n = 5? f = 1 i=1; While (i<=n) f=f*i; i=i+1;
- A) 5
- B) 24
- C) 720
- D) 120
If While (i<=n) ,The loop will keep executing until “i” remains
- A) Less than n
- B) Greater than and equal to n
- C) Equal to n
- D) Less than or equal to n
Sequential Search Algorithm technique _________ in success.
- A) is fast
- B) does not always result
- C) is always optimal
- D) always result
What will be the output of the following pseudo code?
{20, 58, 90, 10, 15, 87, 30, 12, 98}
Count = 0
For number in list
If (number >=50)
Count=count+1
- A) 2
- B) 4
- C) 5
- D) 3
What is the significance of the term "posttest" in loop structures?
- A) Loop testing performed in parallel
- B) Test for termination after loop execution
- C) Test for termination before loop execution
- D) Continuous testing during loop execution
Why is the else-statement used in an if-statement?
- A) To execute a block of code if the condition is false
- B) To handle errors in the program
- C) To execution a block of code multiple times
- D) To execute a block of code if the condition is true
What is the purpose of the given pseudo-code? f = 1 i=1; While (i<=n): f=f*i; i=i+1;
- A) To sort the number list
- B) To identify prime numbers
- C) To determine the maximum value in a list
- D) To calculate the factorial of a given number
How many comparisons are required to sort the elements using insertion sort algorithm?
13, 10, 9, 6, 33, 100
- A) 9
- B) 5
- C) 7
- D) 3
What will be the output of the following pseudocode? marks = 60 if (marks>60) Print(You have passed the examination) Else Print(You have failed the examination)
- A) Both messages will be displayed
- B) No message will be displayed
- C) You have failed the examination
- D) You have passed the examination
What is the ASCII code for alphabet “A”?
- A) 64
- B) 62
- C) 63
- D) 65