Our site uses cookies. Some of the cookies we use are essential for parts of the site to operate and have already been set. You may delete and block all cookies from this site, but parts of the site will not work. To find out more about cookies on this website, see our Cookie Policy
Accept
© eRevision.uk and ZigZag Education 2025
This test is run by .
Note that your final mark will not be saved in the system.

Data Structures / Structured Programming GapFill

Target Level
4-5
Running Total
0
0%
Attempt
1 of 3

You must fill all the gaps before clicking ‘Check Answers!’

One of the key skills of a good programmer is the ability to break a problem down into smaller sections so that each section becomes easier to solve. This means that different sections of the whole solution can be completed by different people and these separate modules are much easier to  changetestwriteimproveand correct before they are put together in the whole solution. In addition, as the modules of code are  improvedseparatealtereddifferent they can be re-used in different parts of the solution, for example: opening or saving a file.

This  practicecodedstructureddesignedapproach to programming can be achieved through the use of  designsinformationsubroutinesvalues. This is a block of code which is defined outside the main body of the program, when a  useaccessworkcall is made in the main program to the subroutine, control of the program passes temporarily to the subroutine until it has been completed, when it returns to the main program. Each subroutine is given its own  designusageidentifiermodule which is used in the main program to ‘call’ the subroutine which is always followed a set of brackets.

 

Examples:


SUBROUTINE multiply_nums(a,b)

     total = a * b

     OUTPUT total

ENDSUBROUTINE

 

SUBROUTINE get_nums(t)

     OUTPUT 'Enter your', t, 'number'

     num ← USERINPUT

     RETURN num

ENDSUBROUTINE

 

a = get_nums('first')

b = get_nums('second')

multiply_nums(a,b)

SUBROUTINE calc_circle_a()

     OUTPUT 'Enter circle radius'

     r ← USERINPUT

     PI ← 3.1459

     area ← PI * r**2

     RETURN area

ENDSUBROUTINE


calc_circle_a()

 

When a subroutine needs data in order to work this is shown as  cellsvariableschangesparameters inside the  usesdesignscellsbrackets, when the subroutine is designed these are just placeholders with the actual values being supplied when the subroutine is called. Subroutines can also  backupreturnfactorknowledge data back into the main program for use in other subroutines and so pass data between subroutines. Subroutines that are designed to RETURN values are called  subscodesfunctionsroutines; subroutines that do not return a value are called  proceduresmodulesroutinessystems.

It is good programming practice to use  externallocalsysteminternal variables wherever possible, the variables used in the example ‘calc_circle_a’ above are local variables as they only exist inside the subroutine .They are not part of the main program which cannot access these; for example if a programmer tried to write PRINT(area) in the main program this would cause an error.


This is your 1st attempt! You get 3 marks for each one you get right. Good luck!

Pass Mark
72%