0% found this document useful (0 votes)
24 views17 pages

Computer Science: Caie Igcse

The document outlines the Program Development Life Cycle (PDLC) in computer science, detailing stages such as analysis, design, coding, testing, and maintenance. It emphasizes the importance of algorithm design, including the use of pseudocode and flowcharts, as well as the significance of testing with normal, abnormal, and boundary data. Additionally, it covers the concepts of variable declaration, data types, and error identification through trace tables.

Uploaded by

pkpsb9zj6c
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)
24 views17 pages

Computer Science: Caie Igcse

The document outlines the Program Development Life Cycle (PDLC) in computer science, detailing stages such as analysis, design, coding, testing, and maintenance. It emphasizes the importance of algorithm design, including the use of pseudocode and flowcharts, as well as the significance of testing with normal, abnormal, and boundary data. Additionally, it covers the concepts of variable declaration, data types, and error identification through trace tables.

Uploaded by

pkpsb9zj6c
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/ 17

CAIE IGCSE

COMPUTER
SCIENCE

P2
CAIE IGCSE COMPUTER SCIENCE

The program or set of programs is developed based on


1. Algorithm Design & the design.
Each module of the program is written using a suitable
Problem-Solving programming language.
Testing is conducted to ensure that each module
functions correctly.
1.1. Program Development Life Cycle Iterative testing is performed, which involves conducting
(PDLC) modular tests, making code amendments if necessary,
and repeating tests until the module meets the required
Analysis functionality.
Design
Coding Testing
Testing
Maintenance The completed program or set of programs is executed
multiple times using various test data sets.
Analysis This testing process ensures that all the tasks within the
program work together as speci ed in the program
Before solving a problem, it is essential to de ne and design.
document the problem clearly, known as the Running the program with di erent test data can identify
"requirements speci cation" for the program. and address potential issues and errors.
The analysis stage involves using tools like abstraction The testing phase aims to verify the overall functionality
and decomposition to identify the speci c requirements and performance of the program by evaluating its
for the program. behaviour with various inputs.
Abstraction focuses on the essential elements needed
for the solution while eliminating unnecessary details 1.2. Structure Diagrams
and information.
Decomposition involves breaking down complex Every computer system is made up of sub-systems, which
problems into smaller, more manageable parts that can are in turn made up of further sub-systems. Structure
be solved individually. Diagrams – The breaking down of a computer system into
Daily tasks can be decomposed into constituent parts for sub-systems, then breaking each sub-system into smaller
easier understanding and solving. sub-systems until each one only performs a single action. A
structure diagram diagrammatically
Design represents a top-down design. Example below.

The program speci cation derived from the analysis


stage is used as a guide for program development.
During the design stage, the programmer should clearly
understand the tasks to be completed, the methods for
performing each task, and how the tasks will work
together.
Documentation methods such as structure charts,
owcharts, and pseudocode can be used to document
the program's design formally.
1.3. Pseudocode & Flowcharts
Coding and iterative testing

Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
WWW.ZNOTES.ORG authorised for personal use only by Rafay at Bloomfeild Hall on 23/10/24.
CAIE IGCSE COMPUTER SCIENCE

Pseudocode - Verbal representation of an algorithm (a Declaration & Usage of Variables & Constants
process or set of steps) and owcharts are a Variable – Store of data which changes during
diagrammatic representation. execution of the program (due to user input)
Flowcharts: A owchart shows diagrammatically the Constant – Store of data that remains the same
steps required to complete a task and the order that during the execution of the program
they are to be performed Basic Data Types
Algorithm: These steps, together with the order, are Integer – Whole Number e.g. 2; 8; 100
called an algorithm Real – Decimal Number e.g. 7.00; 5.64
Char – Single Character e.g. a; Y
String – Multiple Characters (Text) e.g. ZNotes; COOL
Boolean – Only 2 Values e.g. True/False; Yes/No; 0/1
Input & Output (READ & PRINT) – Used to receive and
display data to the user respectively. (Itisrecommended
touseinputandoutputcommands)

INPUT Name
OUTPUT "Hello Mr." , Name

// Alternatively //

READ Name
PRINT "Hello Mr," , Name
An example of a owchart is given below from a past paper
question in which all of the functions of a owchart are Declaration of variable - A variable/constant can be
shown: declared by the following manner

DECLARE [Variable Name] : [DATATYPE OF VARIABLE]

Array: Array is similar to variable but it can store


multiple values of same datatype under single name

DECLARE [ARRAYNAME] : ARRAY [Lower Limit : Upper Lim

Assignment - Each variable is assigned using a left


arrow.

[VARIABLE NAME] <---- [Value to be assigned]


ArrayName [IndexValue] <---- [Value to be assigned]

Conditional Statements:
This owchart’s task is to check if a rider’s height is more the
IF…THEN…ELSE…ENDIF
requirement (1.2) in this case. It then counts until the
accepted riders are 8. After they are 8, it outputs the
number of rejected riders and tells the rest that they are
ready to go!

2. Pseudocode

Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
WWW.ZNOTES.ORG authorised for personal use only by Rafay at Bloomfeild Hall on 23/10/24.
CAIE IGCSE COMPUTER SCIENCE

Loop Structures:

FOR…TO…NEXT : Will run for a determined/known

REPEAT… UNTIL – Will run at least once till condition is


satis ed; Veri cation is done after running code

CASE…OF…OTHERWISE…ENDCASE – Multiple conditions and


corresponding consequences \n

WHILE…DO…ENDWHILE – May not ever run; Veri cation


is done before running code

Note: When using conditions in these loop structures


and conditional statement, it has to be kept in mind that
it can be done in two ways.
1. use of a Boolean variable that can have the value
TRUE or FALSE
2. comparisons made by using coparison operators,
where comparisons are made from left to right

IF [BOOLEAN VARIABLE]
THEN
OUTCOME
ELSE
OUTCOME
ENDIF

IF ((CONDITION 1) OR ( CONDITION 2)) AND (CONDITION


THEN
OUTCOME
ELSE
OUTCOME
ENDIF

Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
WWW.ZNOTES.ORG authorised for personal use only by Rafay at Bloomfeild Hall on 23/10/24.
CAIE IGCSE COMPUTER SCIENCE

MaxiumumValue <--- Array[1] MinimumValue <--- Array[


2.1. FOR Counter ← 2 TO LoopLimit
IF Array[Counter] > MaximumValue
THEN
MaximumValue ← Array[Counter]
ENDIF

IF Array[Counter] < MinimumValue


THEN
MinimumValue ← Array[Counter]
ENDIF
NEXT Counter

// Average//

Total ← 0
2.2. Standard methods used in FOR Counter ← 1 TO NumberOfValues
algorithm: Total ← Total + StudentMark[Counter]
NEXT Counter
Totalling :Totalling means keeping a total that values are Average ← Total / NumberOfValues
added to
Linear Search: In a linear search, each item in the list is
Total ← 0 inspected sequentially until a match is found or the
FOR Counter ← 1 TO LoopLimit entire list is traversed.
Total ← Total + ValueToBeTotalled
NEXT Counter
INPUT Value
Counting: Keeping a count of the number of times an Found ← FALSE
action is performed is another standard method. Counter ← 0
REPEAT
PassCount ← 0 IF Value = Array[Counter]
FOR Counter ← 1 TO LoopLimit THEN
INPUT Value
Found ← TRUE
IF Value > Range
ELSE
THEN
Counter ← Counter + 1
PassCount ← PassCount + 1
ENDIF
ENDIF UNTIL Found OR Counter > NumberOfValues
NEXT Counter IF Found
THEN
Maximum, minimum and average : Finding the largest
OUTPUT Value , " found at position " , Counter, "
and smallest values in a list are two standard methods
ELSE
that are frequently found in algorithms
OUTPUT Value , " not found."
ENDIF

Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
WWW.ZNOTES.ORG authorised for personal use only by Rafay at Bloomfeild Hall on 23/10/24.
CAIE IGCSE COMPUTER SCIENCE

Bubble Sort: Iteratively compare and swap adjacent


elements in a list to sort them. Start from the rst 3.3. Extreme Data
element and continue until the second-to-last element.
After each pass, the last element is in its correct place. Extreme data are the largest and smallest values that
However, other elements may still be unsorted. Repeat normal data can take
the process, excluding the last element, until only one e.g. in a program where only whole number values
element remains or no swaps are needed. ranging from 0 to 100 (inclusive) are accepted, extreme
data will be: 0 and 100
First ← 1 Last ← 10 REPEAT Swap ←
FALSE FOR Index ← First TO Last - 1 3.4. Boundary Data
IF Array[Index] > Array[Index + 1]
This is used to establish where the largest and smallest
values occur At each boundary two values are required:
one value is
THEN accepted and the other value is rejected.
Temp ← Array[Index] e.g. in a program where only whole number values
Array[Index] ← Array[Index + 1] ranging from 0 to 100 (inclusive) are accepted, one
Array[Index + 1] ← Temp example of boundary data will be: 100 and 101. 100 will
Swap ← TRUE be accepted and 101 will not be accepted
ENDIF
NEXT Index
Last ← Last - 1 4. Trace Table
UNTIL (NOT Swap) OR Last = 1
A trace table is utilized to document the outcomes of
every step in an algorithm. It is employed to record the
3. Test Data variable's value each time it undergoes a change.
A dry run refers to the manual process of systematically
Test data refers to input values used to evaluate and executing an algorithm by following each step in
assess the functionality and performance of a computer sequence.
program or system. A trace table is set up with a column for each variable
It helps identify errors and assess how the program and a column for any output e.g.
handles di erent scenarios

3.1. Normal Data


Normal data is the test data which accepts values in
acceptible range of values of the program
Normal data should be used to work through the
solution to nd the actual result(s) and see if they are the Test data is employed to execute a dry run of the owchart
same as the expected result(s) and document the outcomes in a trace table. During the dry
e.g. in a program where only whole number values run:
ranging from 0 to 100 (inclusive) are accepted, normal
test data will be : 23, 54, 64 , 2 and 100 Whenever a variable's value changes, the new value is
recorded in the respective column of the trace table.
3.2. Abnormal Data Each time a value is outputted, it is displayed in the
output column.
Test data that would be rejected by the solution as not
An example of trace table is given below using a past paper
suitable, if the solution is working properly is called
question:
abnormal test data / erroneous test data.
Q: The owchart below inputs the height of children who
e.g. in a program where only whole number values
want to ride on a rollercoaster. Children under 1.2 metres
ranging from 0 to 100 (inclusive) are accepted, abnormal
are rejected. The ride starts when eight children have been
data will be: -1, 151, 200, 67.2, “Sixty-Two” and -520
accepted.

Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
WWW.ZNOTES.ORG authorised for personal use only by Rafay at Bloomfeild Hall on 23/10/24.
CAIE IGCSE COMPUTER SCIENCE

1. Make sure that the problem is clearly understood


which includes knowing the purpose of the algorithm
and the tasks to be completed by the algorithm.
2. Break the problem into smaller problems (e.g. in a
program which outputs average values, divide the
problem into multiple ones i.e. how to count the
number of iterations and how to count the total of all
values)
3. Identify the data that is needed to be saved into
variables/constants/arrays and what datatype it is,
and declare all the variables/constants/arrays
accordingly, with meaningfull names
4. Decide on how you are going to construct your
Complete the trace table for the input data: 1.4, 1.3, 1.1, 1.3,
1.0, 1.5, 1.2, 1.3, 1.4, 1.3, 0.9, 1.5, 1.6, 1.0 algorithm, either using a owchart or pseudocode. If
you are told how to construct your algorithm, then
Riders Reject Height OUTPUT
follow the guidance.
0 0
5. Construct your algorithm, making sure that it can be
1 1.4
easily read and understood by someone else. Take
2 1.3
particular care with syntax e.g. when conditions are
1 1.1 used for loops and selection.
3 1.3
6. Use several sets of test data (Normal, Abnormal and
2 1.0 Boundary) to dry run your algorithm and check if the
4 1.5 expected results are achieved (a trace table can be
3 1.2 used for this purpose) . If error is found, nd the
5 1.3 point of error in the trace table and x it in the code.
6 1.4
7 1.3 Note: The algorithms that you have looked at so far in these
0.9 notes were not designed with readability in mind because
4
1.5 you needed to work out what the problem being solved was.
8 Ready to go 4

5.1. Validation and Veri cation


4.1. Identifying errors:
To ensure the acceptance of reasonable and accurate data
inputs, computer systems must thoroughly examine each data
Trace tables can be used to trace errors in a program.
item before accepting it, and this is where Validation and
For example, if the requirement for the previous
Veri cation come into play!
question would be to accept riders that are of height 1.2
too, rather than rejecting them, then the error would
have been caught in the trace table as when 1.2 is
Validation
entered, it would increment rejected which it shouldn’t in
our example
Validation in computer systems involves automated checks
to ensure the reasonableness of data before accepting it. If

5. How to write an algorithm? the data is invalid, the system should provide an explanatory
message for rejection and allow another chance to enter the
data.
The ability to write an algorithm is very important for this \n There are many types of it.
syllabus and paper. Some key steps/points to be known in-
order to write the perfect algorithm are as follows:
Range check

A range check veri es that a numerical value falls within


speci ed upper and lower limits.

Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
WWW.ZNOTES.ORG authorised for personal use only by Rafay at Bloomfeild Hall on 23/10/24.
CAIE IGCSE COMPUTER SCIENCE

REPEAT OUTPUT "Please enter the value "


INPUT Value REPEAT
IF Value < MinimumValue OR Value > MaximumValue INPUT Value
THEN IF Value = ""
OUTPUT "The student's mark should be in the range" THEN
ENDIF OUTPUT "*=Required "
UNTIL Value >= MinimumValue AND Value <= MaximumValu ENDIF
UNTIL Value <> ""
Length check
Format Check
This can either ensure that data consists of a precise
number of characters. A format check checks that the characters entered conform
to a pre-de ned pattern.
OUTPUT "Please enter your value of ", Limit , " cha
REPEAT Check Digit
INPUT Value
IF LENGTH(Value) <> Limit A check digit is the nal digit included in a code; it is
THEN calculated from all the other digits.
OUTPUT "Your value must be exactly" , Limit ," cha Check digits are used for barcodes, product codes,
ENDIF International Standard Book Numbers (ISBN), and
UNTIL LENGTH(Value) = Limit Vehicle Identi cation Numbers (VIN).

It can also check if the data entered is a reasonable number


Veri cation
of characters or not
Veri cation is checking that data has been accurately copied
OUTPUT "Please enter your value "
from one source to another
REPEAT
There are 2 methods to verify data during entry ( there
INPUT Value
IF LENGTH(Value) > UpperLimit OR LENGTH(Value) < Lo are other methods during data transfer, but they are in
THEN paper 1)

OUTPUT "Too short or too long, please re-enter "


1. Double Entry
ENDIF
UNTIL LENGTH(Value) <= UpperLimit AND LENGTH(Value)
Data is inputted twice, potentially by di erent operators.
The computer system compares both entries and if they
Type check di er, an error message is displayed, prompting the data
to be reentered.
A type check veri es that the entered data corresponds to a
speci c data type.
2. Screen/Visual check
OUTPUT "Enter the value "
REPEAT A screen/visual check involves the user manually reviewing
INPUT Value the entered data. After data entry, the system displays the
IF Value <> DIV(Value, 1) data on the screen and prompts the user to con rm its
THEN accuracy before proceeding. The user can compare the
displayed data against a paper
OUTPUT "This must be a whole number, please re-en
document used as an input form or rely on their own
ENDIF
knowledge to verify correctness.
UNTIL Value = DIV(Value, 1)

Presence check
A presence check checks to ensure that some data has been 5.2. Programming Concepts
entered and the value has not been left blank Constructs of a Program

Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
WWW.ZNOTES.ORG authorised for personal use only by Rafay at Bloomfeild Hall on 23/10/24.
CAIE IGCSE COMPUTER SCIENCE

Data use – variables, constants and arrays Programs require input and output statements to handle
Sequence – order of steps in a task data.
Selection – choosing a path through a program In IGCSE Computer Science, algorithms and programs
Iteration – repetition of a sequence of steps in a program are designed to take input from a keyboard and output
Operators use arithmetic for calculations and logic and to a screen.
Boolean for decisions. Prompting the user with clear instructions for input is
necessary for the user to understand what is expected.
Variables and Constants Input data in programming languages must match the
required data type of the variable where it will be stored.
A variable within a computer program refers to a named By default, inputs are treated as strings, but commands
storage unit with a value that can be modi ed can convert input to integer or real number data types.
throughout the program's execution. To enhance Users should be provided with information about the
comprehension for others, it is advisable to assign output/results for a program to be useful.
signi cant names to variables. Each output should be accompanied by a message
A constant within a computer program represents a explaining the result's meaning or signi cance.
named storage unit that holds a value which remains If an output statement has multiple parts, they can be
unchanged throughout the program's execution. Similar separated by a separator character.
to variables, it is recommended to assign meaningful
names to constants to enhance comprehensibility for
others. 6. File Handling
Data Types Computer programs store data that will be needed again
in a le.
Di erent data types are assigned to computer systems Data stored in RAM is volatile and will be lost when the
for e ective processing and storage. computer is powered o .
Data types allow data, such as numbers or characters, to Data saved to a le is stored permanently, allowing it to
be stored appropriately. be accessed by the same program at a later date or by
Data types enable e ective manipulation using other programs.
mathematical operators for numbers and character Stored data in a le can be transferred and used on
concatenation. other computers.
Some data types provide automatic validation. The storage of data in les is a commonly used feature in
The types of datatypes are told in Chapter 1 already! programming.

Input and Output Key point: When writing in a le, the program is
outputing the data to the le, and when reading a le,
the program in inputing the data from the le
\n There are 3 ways a le can be opened in a program i.e. to
write, to read and to append

6.1. Writing in a le

Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
WWW.ZNOTES.ORG authorised for personal use only by Rafay at Bloomfeild Hall on 23/10/24.
CAIE IGCSE COMPUTER SCIENCE

OPENFILE "filename.txt" FOR WRITE Value1 <--- MOD(10,3) returns the remainder of 10
divided by 3
//When opening a file to write, all the data already Value2 <---- DIV(10,3) returns the quotient of 10 divided
by 3
Value3 <--- ROUND(6.97354, 2) returns the value
WRITEFILE "filename.txt" , Value rounded to 2 decimal places
Value4 <--- RANDOM() returns a random number
// The next command of WRITEFILE would be writen on between 0 and 1 inclusive

CLOSEFILE "filename.txt" 6.5. Creating a Maintainable Program


A maintainable program should:
6.2. Reading a le:
OPENFILE "filename.txt" FOR READ
always use meaningful identi er names for variables,
READFILE "filename.txt" , Variable
// The value in the line (which is identified by the constants, arrays, procedures and functions
be divided into modules for each task using procedures
CLOSEFILE "filename.txt"
and functions
be fully commented using your programming language’s
commenting feature
6.3. Reading a le till EOF:
OPENFILE "filename.txt" FOR READ Commenting in pseudocode:
DECLARE DataVariable : STRING
WHILE NOT EOF("filename.txt) DO // Now the text written is commented and thus ignore
READFILE "filename.txt", DataVariable
// here the line can be outputted or stored in an a "" This method can also be used to comment
//before the file ends has been read multiple lines but the singular line method
ENDWHILE is more widely accepted and reccomended too
""

6.4. Library Routines


Programming language development systems often
7. Programming
provide library routines that can be readily incorporated
into programs. 7.1. Programming Languages
Library routines are pre-tested and ready for use, making There are many high-level programming languages to
programming tasks easier. choose from. We will only be treating Python, Visual
Integrated Development Environments (IDEs) typically Basic, or Java.
include a standard library of functions and procedures.
Standard library routines perform various tasks,
including string handling. Python is an open-source, versatile programming
MOD – returns the remainder of a division language that encourages quick program development
DIV – returns the quotient (i.e. the whole number part) of and emphasises code readability. The integrated
a division development environment (IDE) showcased in this
ROUND – returns a value rounded to a given number of chapter is referred to as IDLE.
decimal places Visual Basic is a popular programming language that is
RANDOM – returns a random number. extensively used for Windows development. The
integrated development environment (IDE) featured in
Examples: this chapter is known as Visual Studio, which is utilised
for capturing screenshots.
Java is a widely adopted programming language utilised
by numerous developers. The integrated development
environment (IDE) employed for capturing screenshots in
this chapter is known as BlueJ.

Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
WWW.ZNOTES.ORG authorised for personal use only by Rafay at Bloomfeild Hall on 23/10/24.
CAIE IGCSE COMPUTER SCIENCE

LENGTH("Text Here")
7.2. Basic Concepts
When writing the steps required to solve a problem, the LENGTH(Variable)
following concepts need to be used and understood:
Extracting a substring from a string:

Sequence SUBSTRING("Computer Science", 10, 7)


Selection // returns the next 7 values starting from the 10th
Iteration SUBSTRING(Variable, Position, Length)
Counting and totalling
String handling Converting a string to upper case
Use of operators.
UCASE("Text here")
Sequence
UCASE(Variable)
The ordering of the steps in an algorithm is very important.
Converting a string to lowercase
An incorrect order can lead to incorrect results and/or extra
steps that are not required by the task. LCASE("Text Here")

Selection LCASE(Variable)

Selection is a very useful technique, allowing di erent routes Arithmetic, Logical and Boolean Operators
through the steps of a program. The code of this is explained in
the notes of previous chapters. As explained in the previous chapter, we already

Iteration Use of Nested Statements

As explained in the previous chapter, we already Selection and iteration statements can be nested,
meaning one statement can be placed inside another.
Totalling and Counting Nested statements help reduce code duplication and
simplify testing of programs.
As explained in the previous chapter, we already Di erent types of constructs can be nested within each
other, such as selection statements within condition-
String Handling controlled loops or loops within other loops.

Strings are used to store text and can contain various


Procedures and Functions
characters.
An empty string has no characters, while the
A procedure refers to a collection of programming
programming language speci es the maximum number
statements organized under a single name, invoked at
of characters allowed. any given point in a program to execute a speci c task.
Characters in a string can be identi ed by their position A function is a compilation of programming statements
number, starting from either zero or one, depending on
consolidated under a singular name, invoked at any
the programming language. moment within a program to accomplish a particular
String handling is an important aspect of programming. task. Unlike a procedure, a function also has the
In IGCSE Computer Science, you will need to write
capability to return a value back to the main program.
algorithms and programs for the following string
Parameters refer to variables that store the values of
methods:
arguments passed to a procedure or function. While not
Length: Determines the number of characters in a all procedures and functions require parameters, some
string, including spaces. utilize them to facilitate their operations.
Substring: Extracts a portion of a string.
Upper: Converts all letters in a string to uppercase. Procedures without parameters:
Lower: Converts all letters in a string to lowercase.
These string manipulation methods are commonly PROCEDURE ProcedureName ()
provided in programming languages through library [Commands]
routines. ENDPROCEDURE
//Calling/running the procedure
Finding the length of a string: CALL ProcedureName()

The procedure with parameters:

Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
WWW.ZNOTES.ORG authorised for personal use only by Rafay at Bloomfeild Hall on 23/10/24.
CAIE IGCSE COMPUTER SCIENCE

PROCEDURE ProcedureName (ParameterName : ParameterDa A two-dimensional array can be referred to as a table


[Commands] with rows and columns.
ENDPROCEDURE
//Calling/running the procedure
CALL ProecdureName (ParameterValue)

Function:

FUNCTION FunctionName (ParameterName : ParameterData


[Commands]
RETURN ValueToBeReturned
ENDFUNCTION

When de ning procedures and functions, the header is


the rst statement in the de nition.
The header includes:
The name of the procedure or function. When a two-dimensional array is declared in pseudocode,
Parameters passed to the procedure or function, the rst and last index values for rows and the rst and last
along with their data types. index values for columns alongside the data type are
The data type of the return value for a function. included.
Procedure calls are standalone statements.
Function calls are made as part of an expression, Declaring a 2D Array:
typically on the right-hand side.
DECLARE Name : ARRAY[RowLower:RowUpper,ColumnLower:C

Local and Global Variable Filling a 2-D array using a loop:

Any part of a program can use a global variable – its FOR ColumnCounter ← 0 TO 2
scope covers the whole program FOR RowCounter ← 0 TO 9
A local variable can only be used by the part of the OUTPUT "Enter next value "
program it is declared in – its scope is restricted to that INPUT ArrayName [RowCounter, ColumnCounter]
part of the program. NEXT RowCounter
NEXT ColumnCounter
Note: Any variables/arrays made in this procedure and
functions will be local and cannot be used out of these.
To be made available all over the program, they must be 8. Boolean Logic
declared globally in the following way.

DECLARE [VariableName] : DataType AS GLOBAL 8.1. Logic Gates and their functions
Six types of logic gates
7.3. Arrays
NOT Gate
An array is a data structure containing several elements
AND Gate
of the same data type; these elements can be accessed
OR Gate
using the same identi er name.
NAND Gate
The position of each element in an array is identi ed
NOR Gate
using the array’s index.
XOR Gate
There are two types of arrays

One-Dimensional Array NOT gate: an inverter, A

A Output
Explained in the previous chapter in detail
0 1
Two-Dimensional Array 1 0

Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
WWW.ZNOTES.ORG authorised for personal use only by Rafay at Bloomfeild Hall on 23/10/24.
CAIE IGCSE COMPUTER SCIENCE

AND gate: A.B

A B Output
0 0 0
0
1
1
0
0
0
9. Writing Logic Statements
1 1 1
Logic Statements is a way of showing all the logics that are in
place for a logic circuit.

9.1. Writing from a logic circuit

OR gate: A +B 1. Look at the ciruit and go around the logic gates used
in the circuit
A B Output
2. Go from the one output that is being given towards
the input
0 0 0
3. Write the last gate ( the rst gate you walk through )
0 1 1
in the middle and then, for each of the value coming
1 0 1
into the gate, leave space at the side
1 1 1
4. If the value coming into the gate is coming from
another gate, use a bracket for the gate’s logic
5. Repeat process 3-4 till you are able to reach the input
values fully

NAND gate: A.B 9.2. Writing from a truth table


A B Output
0 0 1 1. Create logic circuit fom the truth table (shown later)
0 1 1 2. Write the logic statement using the ciruit
1 0 1
1 1 0 9.3. Writing from a Problem statement
1. See what logics go in place in the statement to take

place
2. Go from the logic of any 2 inputs at the start, and
then keep on going until you are able to reach the
NOR gate: A + B nal gate which gives the output
3. When writing the statement, make sure you show the
A B Output logic statement where the output is 1
0 0 1
0 1 0
1 0 0
9.4. Example of a LOGIC STATEMENT
(B AND C) OR (A NOR (A NAND C)) is the logic statement for
1 1 0
the following Logic Circuit

XOR gate: A B

A ⨁B Output
0 0 0
0 1 1
1 0 1
1 1 0

Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
WWW.ZNOTES.ORG authorised for personal use only by Rafay at Bloomfeild Hall on 23/10/24.
CAIE IGCSE COMPUTER SCIENCE

10. Creating Truth Tables


10.1. From Logic Circuits
1. Create a truth table with each input possible, creating
every possible combination of inputs . Tip: For the
rst input, write it in the combination of 1,0,1,0
and so on. For the second, go 1,1,0,0 and so on,
and for the third one, go 1,1,1,1,0,0,0,0 going by
the powers of 2 for each input. This would
guarantee each possible combination
2. Run through the circuit with the inputs and get the 1. Given the truth table above, take the rows where the
output that will be reached and write it accordingly output (x) is 1 (Rows 1, 2, 4, 5, 6, 7)
2. Create a logic expression from these rows (example,
For logic statements, and problem statements, row 1 will be (NOT A AND NOT B AND NOT C) = X
convert them to logic circuits rst and then do the 3. Create logic expressions for all the rows with output
1and connect them with OR gate
rest

10.2. Example 12. Exam-Style Question


This is the example of a truth table of a logic circuit

The circuit:
1. The Conditions are given so make logic statements
using the conditions and the table. (NOT S AND T) OR
(S AND W) OR (NOT T AND W)
2. Make the logic circuit from the given equation
3. Make the truth table

13. Databases
A database is a well-organized compilation of data that
enables individuals to retrieve information according to their
speci c requirements. The data contained within a database
11. Logic Statements from can encompass various forms such as text, numerical
values, images, or any other type of digital content that can
Truth Tables be stored on a computer system.

13.1. Why do we need a database?

Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
WWW.ZNOTES.ORG authorised for personal use only by Rafay at Bloomfeild Hall on 23/10/24.
CAIE IGCSE COMPUTER SCIENCE
Each eld will require a data type to be selected. A data type
To store data about people, things, and events. classi es how the data is stored, displayed and the
Any modi cations or additions need to be made only operations that can be performed on the stored value.
once, ensuring data consistency. The datatypes for database are quite similar to original
All users access and utilize the same set of data, datatypes, however, there are a few di erences.
promoting uniformity.
Relational databases store data in a non-repetitive
manner, eliminating duplication.

13.2. What makes a database?


Data is stored in tables in databases. Each table consists
of a speci c type of data e.g. cars. These tables HAVE to
be named according to what they contain e.g. a table Note: Access datatype refers to the software Microsoft
containing patient information will be PATIENT Access which is a DBMS (DataBase Management
These tables consist of records (rows). Each record System). Here, databases could be worked upon in
consists of data about a single entity (a single item, practical form
person or event ) e.g. a single car
These tables also have columns that are knows an elds. 13.5. Primary Key
These consist of speci c information regarding the
entities that are written later in records e.g. car name, Each record in a table represents a unique item, person,
car manufacturer etc. or event.
To ensure reliable identi cation of these items, a eld
Note: In this chapter, skills of dealing with a database called the primary key is necessary.
are also required so working with Microsoft Access is The primary key is a unique eld that distinguishes each
needed to understand this chapter better. You have to be item within the data.
able to de ne a single-table database from given data In order to serve as a primary key, a eld must have
storage requirements, choose a suitable primary key for a values that are never repeated within the table.
database table and also be able to read, complete and An existing eld can serve as a primary key if it is unique,
understand SQL scripts. such as the ISBN in the book table.
In cases where all existing elds may contain repeated
data, an additional eld, such as "HospitalNumber," can
be added to each record to serve as the primary key.

13.6. Structured Query Language - SQL


Structured Query Language (SQL) is the standard
language for writing scripts to retrieve valuable
Source: Cambridge IGCSE and O Level Computer Science by information from databases.
Hodder Education By using SQL, we can learn how to retrieve and display
speci c information needed from a database.
For instance, someone visiting a patient may only require
13.3. Validation in databases the ward number and bed number to locate them in the
hospital, while a consultant may need a list of the names
Database management software automatically provides of all the patients under their care. This can be done
some validation checks, while others need to be set up using SQL
by the developer during construction.
For example; The software automatically validates elds
SQL Scripts
like "DateOfAdmission" in the PATIENT table to ensure
data input is a valid date. \n

13.4. Basic Data Types

Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
WWW.ZNOTES.ORG authorised for personal use only by Rafay at Bloomfeild Hall on 23/10/24.
CAIE IGCSE COMPUTER SCIENCE

An SQL script is a collection of SQL commands that are


used to perform a speci c task, often stored in a le for
reusability.
To comprehend SQL and interpret the output of an SQL
script, practical experience in writing SQL scripts is
necessary.

Select Statements:

SELECT (fieldsname) FROM


(tablesname) WHERE
(condition) ORDER BY
(sortingcondition) ;

Selecting Sum of values in a table:

SELECT SUM ( fieldsname )


FROM (tablesname) WHERE
(condition) ORDER BY
(sortingcondition) ;

Counting the number of records where the eld


matches a speci ed condition

SELECT COUNT ( fieldsname )


FROM (tablesname) WHERE
(condition) ORDER BY
(sortingcondition) ;

==ORDER BY Field1, Field2, etc. – this speci es a sort in


ascending or alphabetical order starting with the rst
eld.==
==ORDER BY Field1, Field2 DESC – this speci es a sort in
descending or reverse alphabetical order starting with the
rst eld.==
Note: ORDER BY is not necessary to add. It has to be only
added if required!

13.7. Operators
Just like pseudocode, the operators used there can also be
used here for conditions, however, a few more are also used
in databases

Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
WWW.ZNOTES.ORG authorised for personal use only by Rafay at Bloomfeild Hall on 23/10/24.

You might also like