iSchool
.my
Browse subjects
EN
BM
Log in
Sign up
Browse subjects
โบ
Sains Komputer Form 4
โบ Chapter 1: Programming
Two-sided
Tree
Radial
Optimize
๐ Flashcards
This is the free sample โ view-only. Unlock the subject to print on A4.
Unlock Sains Komputer โ RM10
โ
+
Reset / fit
Form 4 ยท Sains Komputer ยท iSchool.my
Chapter 1:
Programming
Computational thinking
โ
Decomposition
Pattern recognition
Abstraction
Algorithm design
Problem-solving
process
โ
Step 1: Analyse problem
and requirements
Step 2: Design
algorithm
Step 3: Code program
Step 4: Test and debug
Step 5: Document and
maintain
Algorithm
representations
โ
Pseudocode
Flowchart symbols
Trace table
Data and operators
โ
Integer, real, Boolean,
character and string
Variables and constants
Arithmetic, relational
and logical operators
Control structures
โ
Sequence
Selection: if / if-else /
switch
Repetition: for / while
/ do-while
Worked algorithm
example: calculate
average
โ
Input three marks: m1,
m2, m3
Process: average = (m1
+ m2 + m3) / 3
Selection: if average โฅ
50 then PASS else FAIL
Example data: 60, 45, 75
Calculation: (60 + 45 +
75) / 3 = 60
Output: average 60,
PASS
Java-style code
example
โ
int total = 0;
for (int i=1; i<=5; i++)
total += i;
System.out.println(total);
Trace: 1+2+3+4+5 = 15
Modular programming
โ
Procedure performs
task
Function returns value
Parameters pass data
Benefits: reuse, testing
and readability
Arrays
โ
Stores same-type
values under one name
Index starts according
to language convention
Loop processes each
element
Errors and testing
โ
Syntax error
Runtime error
Logic error
Normal, boundary and
invalid test data