ZIMFundi
Sign inJoin free

Topic 6 of 8 · Form 3

Programming concepts

Integer, real, char, string and Boolean; declaring and assigning variables and constants.

Notes for this topic 1 file, in order

Create a free account to download PDFs.

  1. PDFProgramming concepts – Computer Science notes (Cambridge O Level)47.3 KB

Variables, constants and data types

Integer, real, char, string and Boolean; declaring and assigning variables and constants.

Input and output

INPUT and OUTPUT statements.

Programming constructs

Sequence, selection (IF … THEN … ELSE … ENDIF; CASE OF … OTHERWISE … ENDCASE) and iteration (FOR … NEXT – count-controlled; REPEAT … UNTIL – post-condition; WHILE … DO … ENDWHILE – pre-condition).

Operators

Arithmetic (+, −, *, /, ^, MOD, DIV), logical (=, <>, <, >, <=, >=) and Boolean (AND, OR, NOT).

String handling

LENGTH, SUBSTRING, UCASE and LCASE.

Procedures and functions

Defined with parameters; functions return values; local and global variables; library routines (ROUND, RANDOM).

Arrays

One- and two-dimensional arrays; iterating with nested loops.

Worked example: Pseudocode to total the values in a 1D array Scores[1:30].

Total ← 0

FOR Index ← 1 TO 30

   Total ← Total + Scores[Index]

NEXT Index

File handling

Opening, reading, writing and closing text files.

Maintainable programs

Meaningful identifiers, comments, procedures and functions.

Exam tip: Use MOD to test for even numbers (Num MOD 2 = 0).

Check yourself

  1. Which loop is guaranteed to run at least once?
  2. What is the value of 17 DIV 5?
  3. Write a statement to output the first three characters of a string Name.
Show answers
  1. REPEAT … UNTIL.
  2. 3
  3. OUTPUT SUBSTRING(Name, 1, 3)
Next topicDatabases

Questions about this topic (0)

No questions about this topic yet.