0% found this document useful (0 votes)
2 views4 pages

IGCSE P2 Revision Notes

The document outlines the Program Development Life Cycle (PDLC), detailing stages such as analysis, design, coding, testing, and maintenance. It discusses various programming concepts including data types, control structures (like loops and conditional statements), and algorithms for tasks such as sorting and searching. Additionally, it covers file handling, validation, verification, and the importance of subroutines and functions in programming.

Uploaded by

yashasnaik08
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

IGCSE P2 Revision Notes

The document outlines the Program Development Life Cycle (PDLC), detailing stages such as analysis, design, coding, testing, and maintenance. It discusses various programming concepts including data types, control structures (like loops and conditional statements), and algorithms for tasks such as sorting and searching. Additionally, it covers file handling, validation, verification, and the importance of subroutines and functions in programming.

Uploaded by

yashasnaik08
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1

Program Development Life Cycle (PDLC) ArrayName [Position] <---- Value to be assigned

 Analysis (Requirements specification, Abstraction-eliminate Conditional Statements/SELECTION

unnecessary details, Decomposition-break problems into smaller IF-ELSE

subproblems)

 Design (Flowcharts, Pseudocodes, Flowcharts)

 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

Note: IF-ELSE/ CASE OF are SELECTION

Loop Structures: (Also known as Iteration)

FOR…TO…NEXT : Count-Controlled Loop; Will run for a

determined/known amount of times

o Variable – Memory Location that stores data which changes

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

 Integer – Whole Number e.g. 2; 8; 100

o Real – Decimal Number e.g. 7.00; 5.64


WHILE…DO…ENDWHILE – Pre-Condition Loop; May not ever run;
o Char – Single Character e.g. a; ‘Y’
Verification is done before running code. Here, the
o String – Sequence of Multiple Characters (Text) e.g. “ZEBA”
Condition has to be TRUE to continue the loop.
o Boolean – Only 2 Values e.g. True/False; Yes/No; 0/1

Input & Output

INPUT identifier/variable

OUTPUT variable, “Message”, ….


Standard methods used in algorithm:
Declaration of variable - A variable/constant can be declared by

the following manner


 Totalling : Totalling means keeping a total that values are added to.

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

[DATATYPE]  Counting: Keeping a count of the number of times an action is

Assignment - Each variable is assigned using a left arrow.(Store) performed is another standard method.

VARIABLE_NAME <---- Value to be assigned


2

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.

NEXT Counter FOR Pass ← 1 to Last-1

 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]

found in algorithms THEN

MaximumValue <--- ArrayName[1] Temp ← Array[Position]

MinimumValue <--- ArrayName[1] Array[Position] ← Array[Position + 1]

Maxpos  0 Array[Position + 1] ← Temp

Minpos  0 ENDIF

FOR Position ← 2 TO END NEXT Position

IF ArrayName[Position] > MaximumValue NEXT Pass

THEN Test Data-It refers to input values that helps identify errors and

MaximumValue ← ArrayName[Position] assess how the program handles different scenarios

Maxpos  Position Normal Data


 Normal data is the test data which accepts values in acceptable
ENDIF
range of values of the program
IF ArrayName[Position] < MinimumValue

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

Sepos  Position accepted.

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

OUTPUT Value , " not found."


3

 e.g. in a program where only whole number values ranging from 0 to


OPENFILE “filename.txt” FOR READ/WRITE
100 (inclusive) are accepted, one example of boundary data will be: CLOSEFILE “filename.txt”

100 and 101. 100 will be accepted and 101 will not be accepted. Writing in a file:

WRITEFILE “filename.txt”, line


 A trace table is utilized to document the outcomes of every step in
Reading a file:
an algorithm. It is employed to record the variable's value each time
READFILE “filename.txt”, line
it undergoes a change.
Library Routines
 A dry run refers to the manual process of systematically executing

an algorithm by following each step in sequence..


 Library routines are pre-tested and ready for use subroutines,

making programming tasks easier.


 Rules: First line is for initialization; Every input/output takes
 Integrated Development Environments (IDEs) typically include a
you to the next line.
standard library of functions and procedures.
Validation (REPEAT….UNTIL)

Validation in computer systems involves automated checks to  Standard library routines perform various tasks, including string

ensure that data is reasonable and within bounds. handling.

 MOD – returns the remainder of a division


 Range check-A range check verifies that a numerical

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

a precise number of characters. places

 Type check-A type check verifies that the entered data  RANDOM – returns a random number.

corresponds to a specific data type. Examples:

 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

left blank  Value3 <--- ROUND(6.97354, 2) returns the value rounded to 2

 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

DD/MM/YYYY etc inclusive

Verification Creating a Maintainable Program

Verification is checking that data has been accurately copied from A maintainable program should:

one source to another


 use meaningful identifiers

There are 2 methods to verify data during entry.


 use subroutines-procedures and functions
1. Double Entry-Data is inputted twice, potentially by different
 have comments. Comments are written using // in pseudocode.
operators.
String Handling
2. Screen/Visual check-A screen/visual check involves the user
 In IGCSE Computer Science, you will need to write algorithms and
manually reviewing the entered data.
programs for the following string methods:
File Handling
o Length: Determines the number of characters in a string, including
Key point: When writing/storing in a file, the program is
spaces.
outputting the data to the file, and when reading a file, the
 Finding the length of a string: LENGTH(String variable
program in inputting the data from the file
or String)
There are 3 ways a file can be opened in a program i.e. to write, to

read and to append  Example 1: LENGTH(“Computer”) returns 8

Opening and Closing a file:


4

 Example 2: Purpose To execute a To execute a sequence of


sequence of statements and return a
X <- “Computer” statements. result.
Return Does not return a Returns a single value.
Y <- LENGTH(X) Value value.
Call Can be called by its Can be called by its name
OUTPUT (Y) name. and used in expressions.
Impact on Can modify global Can modify global variables,
o Substring: Extracts a portion of a string. Variables variables. but primarily used to return
a value.
 Extracting a substring from a string:  When defining procedures and functions, the header is the first

SUBSTRING(Variable, Position, Length) statement in the definition.

 Example:  The header includes: the name of the procedure or function,

 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"

o Upper: Converts all letters in a string to uppercase.


 Any part of a program can use a global variable – its scope covers

the whole program


 UCASE("Text here")

 UCASE(Variable)  A local variable can only be used by the part of the program it is

declared in – its scope is restricted to that part of the program.


 Lower: Converts all letters in a string to lowercase.

 LCASE("Text here")  SQL:

 LCASE(Variable)

Subroutines

A piece of code / a module that is written once and can be called

multiple times.

Advantages of subroutines:

 Programs become easier to read, understand and


 LOGIC GATES:
maintain.

 Easy to test subroutines separately.

 Code reuse.

 Can be called with different sets of data.

Procedures and Functions

Functions can be called as:


variable  FuncName(value1, value2,…)

Feature Procedure Function


Definition A block of code that A block of code that
performs a task. performs a task and returns
a value.

You might also like