MCQ Bank
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
The initialization step in loop structure establishes a starting ________.
- A) Condition
- B) Body
- C) Function definition
- D) Total Number of code lines
Which programming construct is given below? If(condition) Statement A else Statement B
- A) Pointer
- B) Function
- C) Loop structure
- D) Control structure
What is collectively called an assembly language in the context of programming?
- A) Mnemonic system
- B) Compiler
- C) Machine language
- D) High-level language
Which organizations have adopted and published standards for popular programming languages to address the lack of agreement on language definitions?
- A) Compiler Writers Association
- B) International Compiler Consortium
- C) Programming Language Alliance
- D) American National Standards Institute (ANSI) and International Organization for Standardization (ISO)
Why is the Therac-25 incident considered a software failure?
- A) It resulted in a man's death.
- B) The software was believed to be correct.
- C) It occurred in Texas.
- D) There was a technical issue in the software.
What is the role of the test activity in loop control?
- A) To initialize the loop
- B) To execute the loop repeatedly
- C) To modify the loop body
- D) To compare the current state to the termination condition
As a general rule, the use of ___________ produces a higher degree of flexibility that would be obtained merely by explicitly writing the body several times.
- A) Sequential statements
- B) Loop structure
- C)
- D)
In binary search, first of all value check at a point
- A) Most left
- B) Middle
- C) Most right
- D) Beginning
How many times will the loop in the example below execute? int counter=1; while(counter<=5) { cout<<counter; counter=counter+2; }
- A) 4 times
- B) 3 times
- C) 6 times
- D) 5 times