Unit 8 · Programming

8.1 Programming concepts

By the end of this section you should be able to

  • 8.1.1 Declare and use variables and constants
  • 8.1.2 Use integer, real, char, string and Boolean data types
  • 8.1.3 Use sequence, selection and iteration
  • 8.1.4 Use totalling, counting and string handling
  • 8.1.5 Use arithmetic, relational and logical operators
  • 8.1.6 Write procedures and functions with parameters
  • 8.1.7 Use local and global variables and library routines
  • 8.1.8 Write maintainable programs

Lessons

  1. Variables, constants and data types
  2. Sequence, input, output and operators
  3. Selection: IF and CASE
  4. Iteration: FOR, WHILE and REPEAT
  5. String handling and library routines
  6. Validation in code
  7. Maintainable programs, procedures and functions

Key vocabulary

Variable
A named store whose value can change while the program runs.
Constant
A named value that does not change while the program runs.
Selection
Choosing which code to run based on a condition, using IF or CASE.
Iteration
Repeating a section of code, using a loop.
Count-controlled loop
A FOR loop that repeats a set number of times.
Pre-condition loop
A WHILE loop that tests its condition before each repeat.
Post-condition loop
A REPEAT…UNTIL loop that runs at least once and tests its condition at the end.
Procedure
A named block of code that performs a task and does not return a value.
Function
A named block of code that returns a single value.
Parameter
A value passed into a procedure or function.
Local variable
A variable that can only be used inside the subroutine where it is declared.
Global variable
A variable that can be used anywhere in the program.
Loading Bits of Bytes…