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. /A freezer records four temperatures in degrees Celsius: -3, -8, -1 and -6…
MediumComputer ScienceHigh School (9–10)Computer Science › Algorithms and Problem-SolvingNumericalConceptualIGCSE

A freezer records four temperatures in degrees Celsius: -3, -8, -1 and -6…

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.

A freezer records four temperatures in degrees Celsius: −3-3−3, −8-8−8, −1-1−1 and −6-6−6. A programmer uses this algorithm to find the highest.

pseudocode
Highest ← 0
FOR Count ← 1 TO 4
    INPUT Temp
    IF Temp > Highest
      THEN
        Highest ← Temp
    ENDIF
NEXT Count
OUTPUT Highest
  1. What does it output, and why is this wrong?
  1. Rewrite it so that it works for any temperatures, by starting with the first value.

Check your answer

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

Need a reminder? The key ideaShowHide

Totalling: Total ← 0 before the loop, Total ← Total + Value inside. Counting: Count ← 0 before, Count ← Count + 1 inside (often in an IF). Maximum and minimum: start with the first value or an extreme value, and replace it with any larger (or smaller) value. Average: Total / Count after the 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. The given algorithm. Highest starts at 000. No reading is greater than 000, so it never changes. The output is 000, a temperature that was never recorded.

Step 2. The correction.

pseudocode
INPUT Temp
Highest ← Temp
FOR Count ← 2 TO 4
    INPUT Temp
    IF Temp > Highest
      THEN
        Highest ← Temp
    ENDIF
NEXT Count
OUTPUT Highest

Step 3. The new run. Highest starts at −3-3−3. Then −8-8−8 is not larger; −1-1−1 is larger, so Highest becomes −1-1−1; −6-6−6 is not larger. The output is −1-1−1.

Answer: (a) 000, because the starting value is higher than every reading; (b) the corrected algorithm outputs −1-1−1.

Watch out. The loop now runs from 222 to 444, because the first value was input before the loop.

Log in to save this for later
← All Problems
← A school weather station records the rain each day, in millimetres…This is the kind of long scenario question that ends Paper 2… →
More onComputer Science › Algorithms and Problem-Solving

Discussion (0)

Log in to join the discussion.

Loading…

Learn it in

  1. Totalling, counting, maximum, minimum and averageStandard Algorithms: Totals, Searching, Sorting and Validation

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
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 →