MCQ Bank
What is the purpose of the provided pseudocode? 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) Counting the number of elements in a list
- B) Finding the maximum number in a list
- C) Finding the average of a list
- D) Sorting a list in ascending order
Write an if-statement to check if a variable temperature is above 30 degrees Celsius and print "High temperature" if true.
- A) if (temperature < 30) { cout << "High temperature"; }
- B) if (temperature >= 30) { cout << "High temperature"; }
- C) if (temperature == 30) { cout << "High temperature"; }
- D) if (temperature > 30) { cout << "High temperature"; }
The binary search algorithm uses…….
- A) Linear search
- B) Bubble sort technique
- C) Divide and conquer method
- D) Quick sort technique
In insertion sort, how will the array of elements look like after second comparison?
{34, 8, 64, 51, 32, 21}
- A) 8, 34, 64, 51, 32, 21
- B) 8, 21, 32, 34, 51, 64
- C) 8, 34, 51, 64, 32, 21
- D) 8, 32, 34, 51, 64, 21
What is the primary focus of a programmer in a declarative programming system?
- A) Describing algorithms
- B) Developing problem-solving algorithms
- C) Writing procedural code
- D) Developing a precise statement of the problem
How many iterations are required to find 90 in the following array?
{5, 6, 77, 90, 99}
- A) 3
- B) 2
- C) 1
- D) 4
In the context of a loop structure, which part is called the body of the loop?
- A) The termination condition
- B) The collection of instructions executed repetitively
- C) The control process
- D) The initial condition
How does the loop structure contribute to the flexibility of an algorithm?
- A) By reducing the flexibility of the algorithm.
- B) By allowing for a variable number of iterations.
- C) By explicitly writing the body multiple times.
- D) By increasing the error-proneness.
This finding maximum number function will keep on going until we reach at the last value
[12,18,299,38,999,89,101,500,801,45]
- A) 38 each time
- B) 45 each time
- C) 12 each time
- D) 801 each time
How many times the loop condition will be evaluated for n = 5? f = 1 i=1; While (i<=n) f=f*i; i=i+1;
- A) 1
- B) 10
- C) 4
- D) 6
What does the variable "f" represent in the pseudo-code? f = 1 i=1; While (i<=n): f=f*i; i=i+1;
- A) The factorial of the number
- B) The condition for loop termination
- C) The initial value of the loop
- D) The loop counter
What distinguishes the declarative paradigm from the imperative paradigm in programming?
- A) The use of pre-established algorithms
- B) Describing algorithms for problem-solving
- C) The emphasis on procedural programming
- D) Developing precise statements of problems
When applied to a list with n entries, the binary search algorithm will interrogate an average of ------ entries
- A) Nlogn
- B) Log2n
- C) N
- D) Logn
_________loop structure referred to as a post-test loop
- A) For each
- B) For
- C) Repeat
- D) While
Polya’s analysis of problem solving is to evaluate the solution for
- A) Time
- B) Cost
- C) Consistency
- D) Accuracy
Under ________ paradigm a program is viewed as an entity that accepts inputs and produces outputs.
- A) Imperative
- B) Declarative
- C) Functional
- D) Object-Oriented
If the test for termination of a loop is executed after the execution of body then loop is known as……
- A) Pre-test loop
- B) Final loop
- C) Termination loop
- D) Post-test loop
There are….. iterations in following pseudo code.
def FindFactorial():
fact = 2
i=1;
While (i<=7)
fact=fact*i;
i=i+1;
print(fact)
- A) 7
- B) 3
- C) 5
- D) 2
What is the primary goal when sorting a list of names using the insertion sort algorithm?
- A) Create extra space for adding new names in the list
- B) Create a copy of the list for sorting
- C) Move the list to another location
- D) Shuffle entries to sort the list within itself
What will be the output of the following statement?
int a = 10 + 4.867;
- A) 14.867
- B) 14
- C) Compiler error.
- D) 10