Programming

Advanced programming concepts and techniques.

Topics

Key terms

11.1 Programming basics

Variable
A named storage location whose value can change while the program runs.
Constant
A named value that is set once and cannot change while the program runs.
Identifier
The name given to a variable, constant, subroutine or other item in a program.
Assignment
Storing a value in a variable.
Type casting
Converting a value from one data type to another, for example a string to an integer.
Arithmetic operators
Operators such as +, -, *, / , DIV and MOD that perform calculations.
Comparison operators
Operators such as =, <>, <, > and >= that compare values and give TRUE or FALSE.
Logical operators
AND, OR and NOT, used to combine or reverse Boolean conditions.
Concatenation
Joining two or more strings together.

11.2 Selection and iteration

Selection
Choosing which instructions to run, depending on a condition.
Nested selection
A selection statement placed inside another selection statement.
Iteration
Repeating a block of instructions.
Count-controlled loop
A loop that repeats a fixed number of times.
Condition-controlled loop
A loop that repeats until or while a condition is met.
Nested loop
A loop placed inside another loop. The inner loop runs fully for each pass of the outer loop.
Infinite loop
A loop whose condition never causes it to end.

11.3 Structured programming

Subroutine
A named, reusable block of code. It can be a procedure or a function.
Procedure
A subroutine that performs a task and does not return a value.
Function
A subroutine that returns a value to the code that called it.
Parameter
A variable named in a subroutine's definition that receives a value when it is called.
Argument
The actual value passed to a subroutine when it is called.
Passing by value
A copy of the value is passed, so the original variable is not changed.
Passing by reference
The address of the variable is passed, so the subroutine can change the original.
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.
Library routine
A pre-written, tested subroutine that can be used in your own programs.
Modular programming
Building a program from separate subroutines that each do one job.

11.4 Strings

String handling
Operations that work with text, such as finding its length or extracting part of it.
LENGTH
Returns the number of characters in a string.
SUBSTRING
Returns part of a string, starting at a given position for a given length.
UCASE and LCASE
Convert a string or character to upper case or lower case.
ASC and CHR
ASC gives the character code of a character. CHR gives the character for a code.

11.5 Writing maintainable programs

Maintainable code
Code that is easy to read, understand, test and change.
Meaningful identifiers
Names that describe what a variable or subroutine is for, such as totalScore.
Comments
Notes in the code that explain what it does. The computer ignores them.
Indentation
Spacing that shows the structure of the code and makes it easier to read.

Practice questions for Programming