0% found this document useful (0 votes)
50 views5 pages

O Level Loops Practice Test Guide

Uploaded by

ekta chawla
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views5 pages

O Level Loops Practice Test Guide

Uploaded by

ekta chawla
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

O Level Practice Test: WHILE and REPEAT UNTIL Loops

Section A: Fill in the blanks


1. A WHILE loop checks the condition at the _______ of the loop.

2. A REPEAT UNTIL loop always runs at least _______.

3. The condition in a WHILE loop must be _______ for the loop to run.

4. A REPEAT UNTIL loop will stop when the condition becomes _______.

Section B: Output Prediction


1.

x <- 1

WHILE x <= 3 DO

OUTPUT x

x <- x + 1

ENDWHILE

2.

x <- 5

REPEAT

OUTPUT x

x <- x - 1

UNTIL x < 3

Section C: Trace Table


Complete the trace table for the following code:

x <- 2
WHILE x < 6 DO

x <- x + 1

OUTPUT x

ENDWHILE

Iteration | x (before loop) | Output

----------|------------------|--------

1 | |

2 | |

3 | |

4 | |

Section D: Write the Pseudocode


1. Write pseudocode using a WHILE loop to:

- Start from 10

- Keep subtracting 2

- Stop when the number is less than or equal to 0

2. Write pseudocode using a REPEAT UNTIL loop to:

- Ask the user to enter a number

- Keep asking until the number is greater than 0

Section E: Identify the Error


1.

x 0

WHILE x = 5 DO

OUTPUT x

x x+1

ENDWHILE
2.

REPEAT

OUTPUT "Welcome"

UNTIL TRUE
Section F: Scenario-Based Pseudocode Writing
1. Password Check

Keep asking the user to enter a password until they type "admin123".

2. Number Sum

Keep asking the user to enter numbers. Add them to a total. Stop when the user enters 0. Then

output the total.

3. Countdown Timer

Start from 10 and count down to 1. Output each number on a new line.

4. Even Number Entry

Ask the user to enter a number. Repeat until they enter an even number.

5. Menu Choice

Display a menu with choices:

1. Start Game

2. Settings

3. Exit

Keep asking for a valid choice until the user selects option 3 to exit.

6. Guess the Number

The correct answer is 7. Ask the user to guess the number.

Keep repeating until they guess correctly. Then print "Correct!".

7. Multiples of 3

Print the first 5 multiples of 3 using a loop.

8. Age Validation

Ask the user to enter their age.

Repeat until the age is between 1 and 120.

9. Password Confirmation

Ask the user to enter a password and confirm it.

Repeat until both entries match.


10. Enter Marks

Ask the user to enter marks for 5 students. After all entries, print "Data Collected".

You might also like