Multiple choice › Algorithms (loops)
Algorithms (loops)
1. Algorithms (loops)
Consider the algorithm fragment. REPEAT DoThis UNTIL x<=5 OR y=8 Which of the following is logically equivalent?
- DoThis WHILE x>5 AND Y< >8 DoThis ENDWHILE
- DoThis WHILE x<=5 AND y=8 DoThis ENDWHILE
- DoThis WHILE x<=5 OR y=8 DoThis ENDWHILE
- DoThis WHILE x>5 OR Y< >8 DoThis ENDWHILE
Answer
A
NESA answer key: A. REPEAT ... UNTIL (x<=5 OR y=8) continues while NOT(x<=5 OR y=8) = x>5 AND y<>8, and the body runs at least once. Old syllabus (SDD): useful as overlap practice only.