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.

Programming Concepts GapFill

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

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

Once you have decided on an algorithm to solve a problem, it is useful to think about the programming constructs that you will need to use.


For example, in this algorithm:

Step 1: Get user input
Step 2: Ask the user if they would like to make a substring from their input
Step 3: If they say yes, ask them for the start position and length of their desired substring
Step 4: Set the value of the input to be the substring specified by the user
Step 5: Repeat the previous three steps until the user says no
Step 6: Output the final value of the input


We can see from   Step 1Step 4Step 2Step 3 above that the algorithm will require some sort of selection. We can see from   Step 5Step 1Step 3Step 2 that it will also require iteration.


To start programming the algorithm, we should start from the first step and follow each step through in order. First, we get input from the user:


PRINT('Enter a word or phrase')

userString  ← USERINPUTstr= INPUTchar

 responseanswerresultstring = ''


The response of the user input is stored as 
 a constanta variablean assignmentan operator so that it can be used and edited later. We then move on to the next step, asking the user if they would like to make a substring from their input:

PRINT('Would you like to make a substring of '+ userString + (y/n)')

response ← USERINPUT


The next two steps depend on the result of the entry so we need a   functioniterationselectionsequence statement:

     PRINT('Would you like to make a substring of '+ userString + (y/n)')

     response ← USERINPUT

     IF  stringentryinputresponse ='y' THEN

           PRINT('Enter the start position of your new substring')

           subStrStart ← USERINPUT

           PRINT('Enter the end position of your new substring')

           subStrEnd ← USERINPUT

           userString ←  SUBSTRING(subStrStart,subStrEnd,userString)substring(subStrEnd, subStrStart)userString(sub,StrStart,StrEnd)userString.start.end(substring)

 

 if endENDIFendbreak

We now need to make the program loop through the necessary steps:

WHILE response  >====!= 'n'   

     ...

 finishfinish whilewhile endENDWHILE


Finally, we output the result:

 print(‘userString’)print USERSTRINGprint “userString”PRINT(userString)


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

Pass Mark
72%