2.2.3

Additional Programming Techniques

These programming techniques build on the fundamentals. You need to understand string manipulation, file handling, arrays and records, functions and procedures, SQL searching with SELECT/FROM/WHERE, and random number generation practically.

14 exam questions 24 flashcards

What you need to know

  • Explain and use string manipulation, file handling, arrays, records, and random number generation.
  • Understand functions and procedures and when each is useful.
  • Explain local and global variables.
  • Use the SQL keywords SELECT, FROM, and WHERE.

Handling Text

String manipulation

Programs often need to join, search, slice, or check pieces of text.

  • Concatenation joins strings together.
  • Slicing takes part of a string.
  • Length checks how many characters are in the string.
  • Case conversion can change text to upper or lower case.

Think practical

String manipulation is usually about making input usable, checking text, or formatting output clearly.

Permanent Storage

File handling

A variable only keeps data while the program is running. A file allows data to be kept after the program closes.

File handling means working with stored data in secondary storage rather than only temporary values in memory. This is why files are used for things like saved game data, account details, logs, or stored results.

  • File handling commonly uses open, read, write, and close.
  • Files let data be stored after the program ends.
  • If data needs to be reused later, file handling is usually needed.

Organising Data

Arrays

An array stores multiple values under one name, usually values of the same type.

At GCSE level, arrays are treated as fixed-length or static structures. That means the size is decided when the array is created rather than growing automatically during the program.

A 2D array can be thought of like a table with rows and columns. This is useful for grids, seating plans, or game boards.

Quick distinction

An array stores many similar items under one name and position number.

Organising Data

Records

A record stores several related fields that belong to one item or one person.

For example, one student record might contain a name, candidate number, and total mark. The fields are not all “more of the same” in the way an array usually is.

Quick distinction

An array stores many similar items. A record stores several related facts about one item.

Structured Code

Functions, procedures, and variable scope

Subprograms make code easier to organise, test, and reuse.

A function is useful when the rest of the program needs a value back, such as a calculated total or a validation result. A procedure is useful when the aim is to carry out a task rather than return a value.

Scope means where a variable can be used. Local variables stay inside the subprogram that created them. Global variables can be accessed more widely, which can be useful but can also make code harder to manage.

  • A function carries out a task and returns a value.
  • A procedure carries out a task but does not return a value.
  • Local variables are only available inside the subprogram.
  • Global variables are available more widely in the program.
  • The same ideas also apply to local and global constants.
  • Arrays can be passed into subprograms and returned from them when a larger group of values needs to be processed.

Databases

Basic SQL

Only the basics are needed here, so keep the SQL simple and purposeful.

Keyword or toolPurpose
SELECTChoose the fields to return
FROMChoose the table to search
WHEREFilter the rows returned

Not required

You do not need advanced SQL such as joins, inserts, updates, or deletes.

Extras You Need

Random number generation

Random numbers are used when a program needs unpredictability, variety, or simulation.

  • Random numbers can be used in games, simulations, or to generate test data.
  • The program usually asks for a random value within a given range.
  • In exam questions, focus on why randomness is useful rather than advanced maths behind it.

Key takeaways

  • String methods let a program join, split, slice, or examine text.
  • Files allow data to be stored permanently beyond the current run of the program.
  • Arrays and records help organise related data in different ways.
  • Functions return values, while procedures perform tasks.
  • Basic SQL lets you select fields, choose a table, and filter rows.

Glossary

Concatenation
Joining strings together.
File handling
Opening, reading, writing, and closing files so data can be stored and reused.
Array
A data structure that stores multiple values under one name.
Record
A group of related fields stored together.
Function
A subprogram that returns a value.
Procedure
A subprogram that performs a task without returning a value.
Scope
The part of the program where a variable or constant can be accessed.
SQL
A language used to query data in a database.

Test yourself

Common questions