logo

Question detail

A programmer has written the same group of instructions in three different places in a program. Explain how using a subroutine could improve this program.

Try the question, check the answer, then read the explanation to understand the curriculum point.

At a glance

Question

Type

practice

Style

Topic

Programming

Exam-style question

Try this first

A programmer has written the same group of instructions in three different places in a program. Explain how using a subroutine could improve this program.

Model answer

What a good answer should say

  • The repeated group of instructions could be placed in one named subroutine.
  • Each of the three locations could then call the subroutine by writing its name in a program statement.
  • This would reduce duplicated code, because the instructions only need to be written once.
  • A meaningful name would also make the program easier to understand.

Explanation

Why this works

A strong answer identifies the creation of one named out-of-line block, explains that the block is called from each required location, and links this to advantages such as reduced duplication, improved readability, and easier maintenance.

Common mistake

No common mistake is linked to this question yet.

Related flashcards

No flashcards are published for this page yet.

Related practice questions

No questions are published for this page yet.