Browse subjects Sains Komputer › Programming
This is the free sample — view-only. Unlock the subject to print on A4.
Form 4 · Sains Komputer · iSchool.myChapter 1:ProgrammingComputational thinkingDecompositionPattern recognitionAbstractionAlgorithm designProblem-solvingprocessStep 1: Analyse problemand requirementsStep 2: DesignalgorithmStep 3: Code programStep 4: Test and debugStep 5: Document andmaintainAlgorithmrepresentationsPseudocodeFlowchart symbolsTrace tableData and operatorsInteger, real, Boolean,character and stringVariables and constantsArithmetic, relationaland logical operatorsControl structuresSequenceSelection: if / if-else /switchRepetition: for / while/ do-whileWorked algorithmexample: calculateaverageInput three marks: m1,m2, m3Process: average = (m1+ m2 + m3) / 3Selection: if average ≥50 then PASS else FAILExample data: 60, 45, 75Calculation: (60 + 45 +75) / 3 = 60Output: average 60,PASSJava-style codeexampleint total = 0;for (int i=1; i<=5; i++)total += i;System.out.println(total);Trace: 1+2+3+4+5 = 15Modular programmingProcedure performstaskFunction returns valueParameters pass dataBenefits: reuse, testingand readabilityArraysStores same-typevalues under one nameIndex starts accordingto language conventionLoop processes eachelementErrors and testingSyntax errorRuntime errorLogic errorNormal, boundary andinvalid test data