IGCSE P2 Revision Notes
IGCSE P2 Revision Notes
Program Development Life Cycle (PDLC) ArrayName [Position] <---- Value to be assigned
subproblems)
Coding
Testing(Trace tables)
CASE…OF…OTHERWISE…ENDCASE – Multiple conditions and
Maintenance
corresponding consequences(SIMILAR TO IF-ELSE)
Algorithm: Ordered steps to solve a problem
during execution of the program (due to user input) REPEAT… UNTIL : Post-condition Loop; Will run at least once till
o Constant – Memory Location that stores data that remains the same condition is satisfied; Verification is done after running code. Here,
during the execution of the program the Condition has to be TRUE to stop the loop.
Basic Data Types
INPUT identifier/variable
Total ← 0
DECLARE [Variable Name] : [DATATYPE OF VARIABLE]
FOR pos ← 1 TO N
Array: It can store multiple values of same datatype under single
Total ← Total + ArrayName[pos]
name
NEXT pos
DECLARE [ARRAYNAME] : ARRAY [Lower Limit : Upper Limit ] OF
Assignment - Each variable is assigned using a left arrow.(Store) performed is another standard method.
PassCount ← 0 ENDIF
FOR Counter ← 1 TO LoopLimit Bubble Sort: Iteratively compare and swap adjacent elements in a
INPUT Value list to sort them. Start from the first element and continue until the
IF Value > Range second-to-last element. After each pass, the last element is in its
THEN correct place. However, other elements may still be unsorted.
PassCount ← PassCount + 1 Repeat the process, excluding the last element, until only one
ENDIF element remains or no swaps are needed.
Maximum, minimum and average : Finding the largest and FOR Position ← 1 to Last -1
smallest values in a list are two standard methods that are frequently IF Array[Position] > Array[Position + 1]
Minpos 0 ENDIF
THEN Test Data-It refers to input values that helps identify errors and
THEN
e.g. in a program where only whole number values ranging from 0 to
100 (inclusive) are accepted, normal test data will be : 23, 54, 64 , 2
MinimumValue ← ArrayName[Position]
and 100
Minpos Position
Abnormal Data
ENDIF
Test data that would be rejected by the solution as not suitable, if
NEXT Position
the solution is working properly is called abnormal test data /
Linear Search: In a linear search, each item in the list is inspected
erroneous test data.
sequentially until a match is found or the entire list is traversed.
e.g. in a program where only whole number values ranging from 0 to
INPUT Value
100 (inclusive) are accepted, abnormal data will be: -1, 151, 200,
Sepos 0
67.2, “Sixty-Two” and -520
FOR Position 1 to LAST
Extreme Data
IF Value = ArrayName[Position] THEN Extreme data are the largest and smallest values that are
ENDIF e.g. in a program where only whole number values ranging from 0 to
NEXT Position 100 (inclusive) are accepted, extreme data will be: 0 and 100
IF Sepos <> 0 Boundary Data
THEN At each boundary two values are required: one value is
OUTPUT Value , " found at position " , Sepos, " in the list." accepted and the other value is rejected.
ELSE
100 and 101. 100 will be accepted and 101 will not be accepted. Writing in a file:
Validation in computer systems involves automated checks to Standard library routines perform various tasks, including string
value falls within specified upper and lower limits. DIV – returns the quotient (i.e. the whole number part) of a division
Length check-This can either ensure that data consists of ROUND – returns a value rounded to a given number of decimal
Type check-A type check verifies that the entered data RANDOM – returns a random number.
Presence check-A presence check checks to ensure that Value1 <--- MOD(10,3) returns the remainder of 10 divided by 3
some data has been entered and the value has not been Value2 <---- DIV(10,3) returns the quotient of 10 divided by 3
Format Check-A format check checks that the characters decimal places
entered conform to a pre-defined pattern LIKE Value4 <--- RANDOM() returns a random number between 0 and 1
Verification is checking that data has been accurately copied from A maintainable program should:
SUBSTRING("Computer Science", 10, 7) parameters passed to the procedure or function, along with their
data types, and the data type of the return value for a function.
// returns the next 7 values starting from the 10th value of
Local and Global Variable
the string "Computer Science" i.e. "Science"
UCASE(Variable) A local variable can only be used by the part of the program it is
LCASE(Variable)
Subroutines
multiple times.
Advantages of subroutines:
Code reuse.