Revision notes

Programming Concepts: Practice

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

Standard symbols
SymbolMeaning
OvalStart or end (terminator)
ParallelogramInput or output
RectangleProcess or calculation
DiamondDecision with yes/no branches
ArrowDirection of flow

Oval starts and ends, parallelogram is input or output, rectangle processes, diamond decides.

— Memory line

Key takeaways: know the five symbols and trace algorithms with a small table of variable values.

Read the full lesson

Lesson 2

Variables, data types and operators

Data types
TypeHoldsExample
IntegerWhole numbers25, -3
Float (real)Numbers with a fractional part3.14
CharacterA single letter, digit or symbol'A'
StringA sequence of characters"India"
BooleanTrue or false onlytrue

= assigns, == compares. % gives the remainder. Multiply and divide before add and subtract.

— Rule to remember

Key takeaways: match the data type to the value, and do not mix up = and ==.

Read the full lesson

Lesson 3

Control structures: decisions and loops

Trace with a table: write each variable after every step. A loop with a condition that never turns false never ends.

— Method to remember

Key takeaways: trace loops with a value table and count repetitions carefully, including the starting and ending values.

Read the full lesson

Lesson 4

Types of errors, languages and paradigms

Errors
ErrorMeaningFound
Syntax errorBreaks the grammar rules of the languageBefore the program runs, by the translator
Runtime errorHappens while running, such as dividing by zeroDuring execution
Logical errorThe program runs but gives a wrong resultBy testing; no error message appears

Syntax error: breaks the grammar. Runtime error: crashes while running. Logical error: runs but wrong answer.

— Rule to remember

Key takeaways: syntax errors block translation, runtime errors stop execution, logical errors give wrong results.

Read the full lesson

Lesson 5

Programming concepts mixed practice

List the variables, update them step by step, and check the boundary.

— Exam method

Key takeaways: trace on paper, watch boundaries and know your three error types.

Read the full lesson

Lesson 6

Output prediction: loops, nested loops and counting problems

Trace table, check the condition at the right moment, count rows.

Read the full lesson

Lesson 7

Expression evaluation drill: precedence, integer division, modulus and logical operators

Precedence from highest to lowest
OrderOperatorsNotes
1Brackets ( )Innermost first
2NOTReverses True and False
3* , / , %Equal rank; work left to right
4+ , -Equal rank; work left to right
5< , <= , > , >= , == , !=Give True or False
6ANDTrue only if both sides are True
7ORTrue if at least one side is True
8= (assignment)Done last: right side first, then store

Brackets, NOT, then * / % left to right, then + -, then comparisons, then AND, then OR.

Read the full lesson

Lesson 8

Classic algorithm problems: primes, factorial, Fibonacci, digits and palindromes

Seven standard algorithms
TaskIdeaKey statements
Factorial of nMultiply 1 x 2 x ... x nf = 1; FOR i = 1 TO n: f = f * i
Sum of digitsPeel off the last digit with % 10, then drop it with / 10WHILE n > 0: s = s + n % 10; n = n / 10
Reverse a numberBuild the reverse digit by digitr = r * 10 + n % 10; n = n / 10
Palindrome numberReverse it and compare with the originalIF reverse == original
Prime testTry divisors from 2 up to the square rootIF n % d == 0 THEN not prime
Fibonacci seriesEach term is the sum of the previous twoc = a + b; a = b; b = c
GCD (Euclid)Replace (a, b) by (b, a % b) until b is 0WHILE b != 0: t = a % b; a = b; b = t

Peel digits with % 10 and / 10; test divisors only up to the square root; Euclid replaces (a, b) by (b, a % b).

Read the full lesson

Lesson 9

Concept and terminology traps: translators, data structures, searching, sorting and OOP

Look-alike pairs
PairDistinguishing fact
Compiler / interpreterA compiler translates the whole program first; an interpreter translates and runs it line by line
Source code / object codeSource code is written by people; object code is the translated machine code
Syntax error / logical errorSyntax error breaks the grammar rules and stops translation; logical error runs but gives wrong results
Runtime error / logical errorA runtime error stops the program while it runs, for example dividing by zero
Stack / queueStack is last in, first out; queue is first in, first out
Linear / binary searchBinary search needs sorted data and halves the range each time
Bubble / selection sortBubble swaps neighbours; selection picks the smallest each time
Local / global variableLocal exists only in its function; global is visible everywhere
Class / objectA class is the blueprint; an object is one thing built from it
Algorithm / programAn algorithm is the plan in steps; a program is the plan written in a programming language
Pseudocode / flowchartPseudocode is words; a flowchart is a diagram

For each pair, remember one fact that only one member of the pair has.

Read the full lesson

Privacy · Terms · Refunds · Delivery