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. /This algorithm should input five marks, each from 0 to 100, and output the highest mark…
HardComputer ScienceHigh School (9–10)Computer Science › Algorithms and Problem-SolvingConceptualcodingIGCSE

This algorithm should input five marks, each from 0 to 100, and output the highest mark…

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.

This algorithm should input five marks, each from 000 to 100100100, and output the highest mark. It has three errors.

pseudocode
Highest ← 100
FOR Count ← 1 TO 4
    INPUT Mark
    IF Mark < Highest
      THEN
        Highest ← Mark
    ENDIF
NEXT Count
OUTPUT "Highest mark: ", Highest
  1. Dry-run it with the marks 454545, 727272, 383838, 909090, 616161. What does it output?
  1. Identify the three errors and write the corrected lines.

Check your answer

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

Need a reminder? The key ideaShowHide

Normal data is accepted. Abnormal data should be rejected. Extreme data is the largest or smallest accepted value. Boundary data is the largest or smallest accepted value and the value next to it that is rejected. Find errors by dry-running with simple data and comparing with the expected result.

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. The dry run. The loop runs 444 times, so only 454545, 727272, 383838 and 909090 are input. Highest starts at 100100100. The test Mark < Highest keeps the smaller value: 454545, then 454545, then 383838, then 383838. The output is 383838.

Step 2. The errors.

  1. FOR Count ← 1 TO 4 takes only four marks. Correction: FOR Count ← 1 TO 5.
  2. Highest ← 100 starts higher than any mark, so no mark can replace it. Correction: Highest ← 0.
  3. IF Mark < Highest finds the lowest mark. Correction: IF Mark > Highest.

Step 3. The corrected algorithm.

pseudocode
Highest ← 0
FOR Count ← 1 TO 5
    INPUT Mark
    IF Mark > Highest
      THEN
        Highest ← Mark
    ENDIF
NEXT Count
OUTPUT "Highest mark: ", Highest

With the same marks it outputs Highest mark: 90.

Answer: (a) 383838; (b) the loop limit, the starting value and the operator, corrected as above to give 909090.

Watch out. With error 2 fixed but error 3 left, the output would be 000. Fix every error, then dry-run again.

Log in to save this for later
← All Problems
← A program asks for the number of a month, a whole number from 1 to 12…A swimming pool gives a teen ticket to anyone aged from 13 to 19, both included… →
More onComputer Science › Algorithms and Problem-Solving

Discussion (0)

Log in to join the discussion.

Loading…

Learn it in

  1. Test data and finding errorsPseudocode, 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 →