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 must sound an alarm whenever its temperature rises above -15 °C…
HardComputer ScienceHigh School (9–10)Computer Science › Automated and Emerging TechnologiesConceptualIGCSE

A freezer must sound an alarm whenever its temperature rises above -15 °C…

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 must sound an alarm whenever its temperature rises above −15 ∘C-15\ ^\circ\text{C}−15 ∘C. A student writes this pseudocode for the microprocessor.

pseudocode
CONSTANT MaxTemp ← -15
INPUT Temperature
IF Temperature < MaxTemp
  THEN
    OUTPUT "Alarm on"
ENDIF

There are two errors. Find them, explain why each one is an error, and write a corrected version.

Need a reminder? The key ideaShowHide

A control loop reads the sensor, compares the reading with the stored values, acts, and repeats for as long as the system runs. Feedback means that what the actuator does changes the next sensor reading. With two stored values, the actuator comes on below the low value and goes off above the high value; between them nothing changes.

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.

Error 1. The comparison is the wrong way round. Temperature < MaxTemp is true for a cold reading such as −20-20−20, so the alarm would sound when the freezer is working well. It must be Temperature > MaxTemp.

Error 2. There is no loop. The program reads the sensor once and stops. A control system must keep reading the sensor for as long as it runs.

A corrected version.

pseudocode
CONSTANT MaxTemp ← -15
WHILE TRUE DO
    INPUT Temperature
    IF Temperature > MaxTemp
      THEN
        OUTPUT "Alarm on"
      ELSE
        OUTPUT "Alarm off"
    ENDIF
ENDWHILE

Check. For −10-10−10, the test −10>−15-10 > -15−10>−15 is true, so the alarm sounds. For −20-20−20 it is false, so the alarm is off. A REPEAT ... UNTIL loop that never ends would also be accepted.

Log in to save this for later
← All Problems
← An office is at 26 °C when the air conditioning leaves it…A farmer grows vegetables in a dry region… →
More onComputer Science › Automated and Emerging Technologies

Discussion (0)

Log in to join the discussion.

Loading…

More on this topic

  1. A filter calls an email unwanted when its score is greater than its dividing line T…Hard
  2. A bank wants software to decide which card payments might be fraud…Hard
  3. A learning filter is given eight emails that users have labelled…Medium
  4. An email service has a filter that moves unwanted messages into a separate folder…Medium
  5. A health centre in a remote area uses an expert system to help a nurse decide whether a patient…Hard
All problems on this topic →