HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Problems
  2. /Dry-run this algorithm and complete a trace table with the columns A, B and OUTPUT…
MediumComputer ScienceHigh School (9–10)Computer Science › Algorithms and Problem-SolvingNumericalIGCSE

Dry-run this algorithm and complete a trace table with the columns A, B and OUTPUT…

StemPy LabContributed by StemPy Lab

Try it on paper first. A hint, the key idea and the worked solution are here when you need them.

Dry-run this algorithm and complete a trace table with the columns A, B and OUTPUT.

pseudocode
A ← 7
B ← 3
REPEAT
    A ← A - B
    B ← B + 1
UNTIL A < B
OUTPUT A, " ", B

What are the final values of A and B, and how many times does the loop body run?

Check your answer

Work it out on paper, then type your number. The answer itself stays hidden.

Need a reminder? The key ideaShowHide

A dry run follows an algorithm by hand. A trace table has a column for each variable and for the output, which includes the user prompts. Write a value only when it changes, and start a new row for each pass of a loop.

The worked solution

Have you tried it?

Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.

Step 1. Start. A is 777 and B is 333.

Step 2. Pass 1. A ← 7 - 3 = 4, then B ← 4. Test 4 < 4: false, so repeat.

Step 3. Pass 2. A ← 4 - 4 = 0, then B ← 5. Test 0 < 5: true, so stop.

Step 4. Output. 0 5.

The trace table, one row per value of A:

  • A 777, B 333;
  • A 444, B 444;
  • A 000, B 555, output 0 5.

Answer: A is 000, B is 555, and the loop body runs 222 times.

Watch out. In pass 1 the test uses the new B, which is 444, not the old 333. With the old value the loop would stop one pass early.

Log in to save this for later
← All Problems
← This is the kind of long scenario question that ends Paper 2…This algorithm adds up positive numbers until it has three of them… →
More onComputer Science › Algorithms and Problem-Solving

Discussion (0)

Log in to join the discussion.

Loading…

Learn it in

  1. Trace tables and dry runsPseudocode, Trace Tables and Testing

More on this topic

  1. This is the kind of long scenario question that ends Paper 2…Hard
  2. A delivery company adds a check digit to each parcel number…Medium
  3. Name the check in each case. Say whether it is validation or verification…Easy
  4. A bubble sort is changed so that it sorts in descending order: the comparison becomes IF…
Hard
  • A shop stores the colours of the ten bicycles in its window in an array Colours: red, blue, red…Medium
  • All problems on this topic →