MCQ Bank
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
What is the purpose of the program given below? if (CGPA>=3.0) cout<<”Give Scholarship”; else cout<<”Sorry you do not qualify for the scholarship”;
- A) Determine if a student qualifies for a scholarship
- B) Calculate the CGPA of a student
- C) Print a student's semester grades
- D) Provide information about university policies
How does a while statement in a loop structure work?
- A) It executes the body only once.
- B) It ignores the condition and executes the body indefinitely.
- C) It checks the condition, then executes the body.
- D) It executes the body and then checks the condition.
What approach does the imperative paradigm uses for the programming process?
- A) Finding an algorithm and expressing it as a sequence of commands
- B) Object-oriented approach
- C) Linear scale development
- D) Functional programming approach
In computer programming, what comes after the "if" keyword in an if-statement?
- A) Else
- B) StatementA
- C) Condition
- D) StatementB
Which one of the following is the traditional approach of programming process?
- A) Functional paradigm
- B) Object oriented paradigm
- C) Imperative Paradigm
- D) Declarative paradigm
In the Java programming language, what is the equivalent term for an "activation" in the context of concurrent processing?
- A) Function
- B) Thread
- C) Task
- D) Operation
Let a list Fred, Alex, Diana ,Byron ,Carol
After sorted first sublist our list would be
- A) Fred, Alex, Diana ,Byron ,Carol
- B) Alex, Fred, Diana ,Byron ,Carol
- C) Alex ,Fred ,Byron, Diana, Carol
- D) Alex, Diana , Fred, Byron ,Carol
What is the role of the semicolon in an assignment statement in most imperative languages?
- A) Marks the end of the program
- B) Initiates a loop
- C) Represents a comment
- D) Separates statements
What does the cyclic pattern of a loop involve?
- A) Checking the condition only at the end of the loop.
- B) Ignoring the condition and executing the body.
- C) Repeatedly checking the condition and executing the body.
- D) Executing the body continuously without interruption.
How many choices are possible when using a single if-else statement?
- A) 4
- B) 3
- C) 1
- D) 2
In background, insertion sort algorithm works on _______ code.
- A) ASCII
- B) UTF-16
- C) ANSI
- D) Hexadecimal
Write a program that prints "Pass" if the CGPA is greater than or equal to 2.0 and "Fail" otherwise.
- A) if (CGPA > 2.0) { cout << "Pass"; } else { cout << "Fail"; }
- B) if (CGPA == 2.0) { cout << "Pass"; } else { cout << "Fail"; }
- C) if (CGPA >= 2.0) { cout << "Pass"; } else { cout << "Fail"; }
- D) if (CGPA < 2.0) { cout << "Pass"; } else { cout << "Fail"; }
The Binary Search Algorithm, what will be the mid value in second level of recursion in the following array.
{45, 77, 89, 90, 94, 99, 100} and key = 99
- A) 89
- B) 90
- C) 99
- D) 94
What would be the next statement?
Def findmax():
Max = first number in the list
Current = second number in the list
While (elements in the list exist)
- A) Max=current
- B) Max=value
- C) Current = next value in the list
- D) If (max<current)