iSchool
.my
Browse subjects
EN
BM
Log in
Sign up
Browse subjects
›
Sains Komputer
› Programming
Two-sided
Tree
Radial
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