NEW
Font size
WorksheetsBSCS 3-5: PPL Final Quiz - 1-28-2025
Total questions: 20
Worksheet time: 7mins
Which of the following is an example of an explicit sequence control structure?
Sequential execution of statements in the order they are written
Use of parentheses in mathematical expressions to specify the order of operations
Built-in rules of precedence in a high-level programming language
Automatic function calls in functional programming languages
Consider the following expression: A = B + D / K. What would be the output if the language adheres strictly to implicit sequence control without parentheses? Assuming: B = 10, D = 20, K = 5
6
14
18
50
Which of the following best demonstrates a postfix (reverse Polish) notation for the expression (A + B) * C?
* + A B C
A B + C *
C * A B +
+ A B C *
In a programming language like Java, which of the following scenarios involves prefix notation?
A++;
A = A + 1;
A += B;
++A;
What will be the output of the following Java code? (see the image)
17
16
15
Compilation Error
Which of the following control structures is least dependent on sequence control?
If-Else statements
Loops
Switch-case structures
Recursive function calls
What is the primary benefit of using prefix or postfix notations in certain languages like Java for increment or decrement operations?
Allows efficient evaluation of expressions without ambiguity
Eliminates the need for operator precedence
Simplifies debugging
Enhances readability of expressions
Which of the following scenarios correctly describes the concept of functional composition in sequence control?
Assigning the output of one function to multiple variables
Replacing a variable value using an explicit sequence
Using nested function calls to define a computation
Writing multiple statements sequentially within a block
For the infix notation A * (B + C), what would be the equivalent prefix notation?
A B C + *
* + B C A
* A + B C
A * + B C
Which of the following statements is true about implicit sequence control?
It requires the programmer to manually specify the order of execution
It is automatically determined by the rules of the programming language
It overrides any parenthesized expressions
It is used only in machine or assembly languages
Which of the following best describes the purpose of pattern matching in Prolog?
Determining the validity of arithmetic expressions
Calculating mathematical operations using logical rules
Matching variables to predefined templates and assigning values
Replacing recursive functions with iterative loops
In the context of unification in Prolog, which of the following queries will succeed given the database facts parent(john, mary). and parent(mary, susan)?
parent(mary, X)
parent(X, john)
parent(susan, mary)
parent(john, X), parent(X, susan)
Which of the following is an example of backtracking in a logical programming language like Prolog?
Searching for all possible matches for a query and undoing partial results if no match is found
Repeatedly iterating over a list to calculate the sum of its elements
Recursively defining a factorial function
Matching a regular expression to a string
Which of the following statements about structured sequence control is true?
It relies heavily on the use of unconditional goto statements
It treats individual statements as single units for execution
It emphasizes hierarchical and modular control structures like loops and conditionals
It does not support compound statements within iteration structures
Consider the following Java code. What will be printed?
2
3
4
5
Which statement is an example of a conditional sequence control structure?
while (x > 0) { x--; }
if (x > 0) { System.out.println(x); }
int x = 5; x = x + 1;
for (int i = 0; i < 10; i++) { System.out.println(i); }
In a program using iteration, which of the following demonstrates a compound statement in the loop body?
for (int i = 0; i < 5; i++) System.out.println(i);
do { System.out.println("Hello!"); } while (false);
int sum = 0; for (int i = 1; i <= 10; i++) sum += i;
while (x > 0) { x--; y += x; }
What is the main difference between an unconditional goto and a conditional goto statement?
Unconditional goto can only be used inside loops
Conditional goto is controlled by a logical expression, while unconditional goto is not
Conditional goto always transfers control to the end of a block
Unconditional goto is supported only in structured programming languages
Which of the following correctly demonstrates a backtracking scenario?
A program uses a for loop to iterate over an array
A recursive function tries all paths in a maze until the destination is found
A switch-case statement evaluates different cases based on a variable’s value
A while loop decrements a value until it becomes zero
Which of the following operations demonstrates explicit sequence control in a high-level language?
Using parentheses to override operator precedence in an arithmetic expression
Writing a function to calculate the sum of two numbers
Declaring a variable before assigning it a value
Passing arguments by value in a function call
