INPUT MyNumber
Location<--0
FOR Index<--1 TO 50
IF Values[Index] = MyNumber
THEN
Location Index
ENDIF
NEXT Index
IF Location = 0
THEN
OUTPUT "Not found"
ELSE
OUTPUT Location
ENDIF
Last <--50
Repeat
Swap FALSE
FOR Index 1 TO Last - 1
IF Values[Index] > Values[Index + 1]
THEN
Temp<--Values[Index]
Values[Index]<--Values[Index + 1]
Values[Index + 1] <--Temp
Swap TRUE
ENDIF
NEXT
Last<--Last - 1
UNTIL NOT Swap or Last = 1
count controlled, the number of iterations is pre-determined
pre-condition, checks condition at the start of loop // loop may not iterate
post-condition, checks condition at end of loop // loop always iterates at least once (1)
simplifying the problem
removing unnecessary details from the problem // selecting elements required
filtering out irrelevant characteristics from those elements
inputs // what is put into the system
processes // actions taken to achieve a result
outputs // what is taken out of the system
storage // what needs to be kept for future use
One mark for a hierarchical structure.
One mark for suitable names for the sub-systems.
One mark for identifiable inputs.
One mark for identifiable outputs
Satellite navigation system
Input destination
New destination
Saved destination
Output directions
Map
List
local variables - scope is a defined block of code/subroutine/procedure/function
global variables – scope is the whole program
local variables - value cannot be changed elsewhere in the program
global variables – value can be changed anywhere in the program
Validation is an automated check carried out by a computer
to make sure the data entered is sensible/acceptable/reasonable
One mark for explaining why a validation check is needed when data is input
To check that data is sensible / reasonable / meets required criteria
One mark for explaining why a verification check is needed when data is input
To check that data is not changed on entry
One mark for an example of a validation check
Range check // Length check // Type check
One mark for an example of a verification check
Double entry // Visual check
To ensure that data has been accurately copied // to ensure that changes have not been made to the values originally
intended when data is copied
... from one source to another
TYPES
Verification check 1 – Visual check
Use – the user looks through the data that has been entered and confirms that no changes have been made.
Verification check 2 – Double data entry
Use – data is entered twice, the two entries are compared and if they do not match, a re-entry is requested.
check that the program works as expected
check for logic/runtime errors
check that the program rejects any invalid data that is input
check that the program only accepts reasonable data
Example
Normal // erroneous // abnormal // extreme // boundary
DIV
To perform integer division
Meaning only the whole number part of the answer is retained
Example of DIV For example DIV(9,4) = 2
ROUND
To return a value rounded to a specified number of digits / decimal places
The result will either be rounded to the next highest or the next lowest value
... depending on whether the value of the preceding digit is >=5 or <5
Example of ROUND for example, ROUND(4.56, 1) = 4.6
MOD
To perform (integer) division when one number is divided by another
... and find the remainder
Allow example e.g. 7 MOD 2 = 1
RANDOM
To generate (pseudo) random numbers
...(usually) within a specified range
Allow example e.g. RANDOM() * 10 returns a random number between 0 and 10
One mark per mark point, max three
Procedures / functions divide the program into smaller manageable segments
... making it more readable / easier to understand / easier to debug
Procedures / functions with meaningful names help to provide documentation for the program / enable/help/provide
abstraction
Procedures and functions may be re-used (in the program / in other
Meaningful identifiers – to enable the programmer (or future programmers) to easily recognize the purpose of a variable / array / constant // to enable easy tracking of a variable / constant / array through the program
Use of comments – to annotate each section of a program so that a programmer can find specific sections / so that the programmer knows the purpose of that section of code
Procedures and functions
– to make programs modular and easier to update / add functionality
use indentation and white space
data is stored permanently
data can be moved to another computer
another copy of data can be made and stored//accessed elsewhere // backup copy
a list / one column of items
... of the same data type
... stored under a single identifier
... with a single index to identify each element
Declaration
Example: DECLARE MyArray[1:10] OF INTEGER
Indexing
using a counter to index the array
so that the same code can be repeatedly used to check every element // every element can be checked in a loop
EmployeeID String Length Check / Presence Check / Format Check / Type check
Manager Boolean Type Check / Presence Check
AnnualHoliday Integer Type Check / Range Check / Presence Check
PayGrade Char Presence Check / Length Check / Type Check