Revision notes

Programming Concepts: Foundation

The key points, rules to remember, tables and diagrams from all 9 lessons, on one page for quick revision. To keep a copy, use your browser's Print and choose "Save as PDF".

Lesson 1

Algorithms and flowcharts

Symbols
SymbolNameUsed for
OvalTerminatorStart and Stop
ParallelogramInput / OutputReading and printing data
RectangleProcessCalculations and assignments
DiamondDecisionYes/No question with two exits
ArrowFlow lineDirection of flow
CircleConnectorJoining parts of a chart

Algorithm = steps. Flowchart = picture of the steps. Pseudocode = steps in plain words.

— Remember
  • Plan with an algorithm before coding.
  • Know the flowchart symbols.
  • Pseudocode is language-free.
Read the full lesson

Lesson 2

Variables, data types and operators

Common data types
TypeHoldsExample
IntegerWhole numbers25, -3
Float (real)Numbers with a decimal part3.14
CharacterA single letter or symbol'A'
StringText"Delhi"
BooleanTrue or falseTrue

A variable's value can change; a constant's cannot. % gives the remainder.

— Remember
  • Variables hold changing values; know the five data types.
  • Learn arithmetic, comparison and logical operators.
  • % is remainder.
Read the full lesson

Lesson 3

Making decisions: if and else

Order matters in an else-if chain: the first true condition wins.

— Remember
  • Selection chooses a path using a condition.
  • else-if chains stop at the first true condition.
  • n % 2 tests even or odd.
Read the full lesson

Lesson 4

Repeating steps: loops

Loops
LoopBehaviourCondition checked
forRepeats a known number of timesBefore each pass
whileRepeats while a condition is trueBefore each pass; may run zero times
do-whileRuns the body, then checks the conditionAfter each pass; runs at least once

A loop needs a start, a condition and a change. while may run zero times; do-while runs at least once.

— Remember
  • Loops repeat steps; for, while and do-while differ in when they check.
  • Trace loops by tracking the variables after each pass.
Read the full lesson

Lesson 5

Functions, errors and ways of programming

Errors
ErrorMeaningExample
Syntax errorBreaking the rules of the language; the program will not runA missing bracket
Runtime errorOccurs while the program runsDividing by zero
Logic errorProgram runs but gives wrong resultsUsing + instead of x

Syntax error = grammar mistake. Runtime error = fails while running. Logic error = wrong answer.

— Remember
  • Functions are reusable named blocks.
  • Know the three error types.
  • OOP uses classes and objects.
Read the full lesson

Lesson 6

Input, output and assignment: writing your first complete programs

Three small programs
ProblemFormula usedSteps
Simple interestSI = P x R x T / 100READ P, R, T; SI = P * R * T / 100; PRINT SI
Celsius to FahrenheitF = C x 9 / 5 + 32READ C; F = C * 9 / 5 + 32; PRINT F
Area of a circleA = 3.14 x r x rREAD r; A = 3.14 * r * r; PRINT A

Input, process, output; the variable on the left of = receives the value on the right; swapping needs a third variable.

  • A program usually reads input, calculates and prints output.
  • In x = x + 1 the new value is based on the old value.
  • Check the order of statements: store first, then use.
Read the full lesson

Lesson 7

Arrays and strings: storing many values under one name

Strings and arrays
IdeaExampleResult
Length of a string"COMPUTER"8
Character at index 0"COMPUTER"C
Character at index 7"COMPUTER"R
Concatenation"Good" + " " + "Day"Good Day
Array elementmarks = [60, 75, 80, 45, 90], marks[2]80

The first index is 0 and the last is length - 1; total first, then divide by length for the average.

  • An array stores many values of one kind under one name.
  • Index counting starts at 0 in most languages.
  • A string is a sequence of characters with its own length and indexes.
Read the full lesson

Lesson 8

From problem to program: the programming cycle, comments, testing and good names

Test plan for the pass rule
Test typeInputExpected output
Normal65Pass
Normal12Fail
Boundary40Pass
Boundary39Fail
Invalid-5An error message

Understand, plan, code, run, test, debug, document. Test normal, boundary and invalid data.

  • Plan before coding; test after coding.
  • Boundary values are where faults hide.
  • Comments and meaningful names make a program easier to maintain.
Read the full lesson

Lesson 9

Combining conditions with AND, OR and NOT

Truth table
ABA AND BA OR BNOT A
TrueTrueTrueTrueFalse
TrueFalseFalseTrueFalse
FalseTrueFalseTrueTrue
FalseFalseFalseFalseTrue

AND needs both; OR needs one; NOT flips. A range inside uses AND; outside uses OR.

  • Use brackets to avoid mistakes in mixed conditions.
  • A range check joins two comparisons with AND.
  • The leap-year rule combines OR, AND and a NOT-equal test.
Read the full lesson

Privacy · Terms · Refunds · Delivery