Browse subjects โ€บ Sains Komputer Form 4 โ€บ Chapter 1: Programming
๐Ÿƒ Flashcards This is the free sample โ€” view-only. Unlock the subject to print on A4.
Form 4 ยท Sains Komputer ยท iSchool.myChapter 1:ProgrammingComputational thinkingโ€“DecompositionPattern recognitionAbstractionAlgorithm designProblem-solvingprocessโ€“Step 1: Analyse problemand requirementsStep 2: DesignalgorithmStep 3: Code programStep 4: Test and debugStep 5: Document andmaintainAlgorithmrepresentationsโ€“PseudocodeFlowchart symbolsTrace tableData and operatorsโ€“Integer, real, Boolean,character and stringVariables and constantsArithmetic, relationaland logical operatorsControl structuresโ€“SequenceSelection: if / if-else /switchRepetition: for / while/ do-whileWorked algorithmexample: calculateaverageโ€“Input 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 codeexampleโ€“int total = 0;for (int i=1; i<=5; i++)total += i;System.out.println(total);Trace: 1+2+3+4+5 = 15Modular programmingโ€“Procedure performstaskFunction returns valueParameters pass dataBenefits: reuse, testingand readabilityArraysโ€“Stores same-typevalues under one nameIndex starts accordingto language conventionLoop processes eachelementErrors and testingโ€“Syntax errorRuntime errorLogic errorNormal, boundary andinvalid test data