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.

Robust and Secure Programming GapFill

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

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

It can be hard to predict every input that a program will need to process, especially when user input is required. When designing a program, it is important to think about all the possible data inputs that your program must be able to handle to ensure that your program is robust and will not crash. Data  correctioncompletionvalidationcorrectness techniques must be included in your program to check the  typelengthsizevalidity of data entered by a user.


There are a number of ways to create simple validation checks, look at these examples:


PRINT('Enter a number between 1 and 20')

num ← USERINPUT

IF num >= 1 AND num <= 20 THEN

     valid ← True

ELSE

     valid ← False

ENDIF

valid ←  CorrectFALSEInputUserInput

PRINT('Enter your name')

WHILE not valid

     name ← USERINPUT

     IF LEN(name)<= 1 THEN

           PRINT('You have not entered any text')

           PRINT('Enter your name')

     ELSE

           valid ← True

     ENDIF

ENDWHILE


The first example is not user-friendly as it gives the end user no information about the validity of their data entry, the second version is an improvement because it gives feedback to the user but this version could continue to loop if the user never enters more than one character. This could be improved by limiting the  informationtypecompletionnumber of attempts before the program exits.

These checks only ensure that data entered is  certaincompletecorrectsensible, they do not check the data entry is correct.  CompletionAuthenticationCheckingInforming is the process of checking that a user is who they claim to be, for example if you want to shop online at a store you will need to create an account with a username and  emailpasswordinformationUserInputwhich are initially checked through email confirmation and double entry of a password.

In this example the authentication process is limited to three attempts:


PRINT('Enter password: ')

password ← USERINPUT

PRINT('Confirm password :')

confirm ← USERINPUT

count ← 3

valid ← False

WHILE count > 0  ORNOT >=AND valid = False

     IF confirm != password THEN

           PRINT('Entry does not match')

     ELSE

           PRINT('Password accepted')

                valid ←  IncorrectincompleteTRUElength

     ENDIF

     PRINT('Confirm password :')

     confirm ← USERINPUT

     count ← count - 1

ENDWHILE


As well as handling any errors that may be introduced by user input, you should also be aware of errors that may be introduced when developing a program. There are two general types of error that can be made:   logicvalidationsyntaxverification errors, that occur when the programming language doesn't recognise a command which it has been given, causing the program to fail to be translated into machine code; and   verificationlogicsyntaxvalidation errors, which are accepted as valid code, but cause the program to do something that the programmer did not intend.

In all cases detailed testing of programs using normal,  limitedcompleteboundaryterminal and extreme data should enable the programmer to identify and correct all errors.


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

Pass Mark
72%