2. Programming
Control Structures — Quiz
Test your understanding of control structures with 5 practice questions.
Practice Questions
Question 1
Which selection structure in pseudocode guarantees that only the first true condition’s branch executes, and no other branches are evaluated?
Question 2
Consider the following pseudocode: count ← 0; FOR i FROM 1 TO 3 DO FOR j FROM 1 TO 2 DO FOR k FROM 1 TO i DO count ← count + 1; END FOR; END FOR; END FOR; OUTPUT count. What is printed?
Question 3
Analyze this pseudocode: x ← 5; WHILE x > 0 DO IF x MOD 2 = 1 THEN x ← x + 1; END IF; END WHILE; OUTPUT x. What issue occurs?
Question 4
What is the time complexity in Big-O notation of the following pseudocode in terms of n? FOR i FROM 1 TO n DO FOR j FROM 1 TO i^2 DO constant_operation; END FOR; END FOR
Question 5
Given this pseudocode: x ← 9; WHILE x > 0 DO IF x = 6 THEN x ← x - 2; CONTINUE; END IF; x ← x - 3; END WHILE; OUTPUT x. What is the output?
