Multiple choice technology programming languages

Consider the following program code: \$y = 1; \$x = 2; \$z = 3; do { print (\$y ); } while (\$y eq 2); do { print (\$x ); } until (\$x eq 2); print (\$z ); What is the result of executing this program code?

  1. The code will output the following:123

  2. The code will output the following: 3

  3. The code will output the following:23

  4. The code will output the following: 321

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The first do-while prints $y (value 1), then checks condition $y eq 2 (false since $y=1), so it exits. The second do-until prints $x (value 2), then checks $x eq 2 (true), so it exits after one iteration. Finally print $z outputs 3. The complete output is '123' printed sequentially.