Curriculum Portal

Select a course.

arrow_back

2.2 Programming Fundamentals

infoWhy this? Programming allows you to move from simply using technology to creating it. By understanding variables, selection, iteration and data types, you gain the skills needed to develop your own software solutions.

scheduleWhy now? Learning programming fundamentals now builds confidence, creativity and computational thinking skills that are increasingly sought after in a technology-driven world.

neurologyYou need to know

  • A variable is a named memory location whose value can change, whereas a constant is a named value that should not change while a program runs.
  • Input supplies data to a program, output communicates processed information, and assignment stores a value in a variable.
  • Sequence executes instructions in order, selection chooses a path according to a condition, and iteration repeats instructions.
  • A count-controlled loop repeats a known number of times, whereas a condition-controlled loop repeats while or until a Boolean condition is met.
  • The arithmetic operators are addition `+`, subtraction `-`, multiplication `*`, division `/`, modulo `MOD`, integer quotient `DIV`, and exponentiation `^`.
  • `DIV` returns the whole-number quotient of a division, while `MOD` returns the remainder.
  • The comparison operators are equal to `==`, not equal to `!=`, less than `<`, less than or equal to `<=`, greater than `>`, and greater than or equal to `>=`; each produces a Boolean result.
  • The Boolean operator AND is true only when both conditions are true, OR is true when at least one condition is true, and NOT reverses a Boolean value.
  • An integer stores a whole number, while a real data type stores a number that may contain a fractional part.
  • A Boolean stores either true or false, a character stores one symbol, and a string stores a sequence of characters.
  • Casting temporarily converts data from one type to another, such as converting a numeric string into an integer so that arithmetic can be performed.
  • Concatenation joins strings together, while slicing extracts a selected section of a string.
  • File handling normally involves opening a file, reading data from it or writing data to it, and then closing it to release the resource and preserve changes.
  • A record groups related fields about one entity, such as a student record containing a name, date of birth and candidate number.
  • An array is a fixed-length, static structure whose elements are accessed using an index; a one-dimensional array forms a list and a two-dimensional array forms rows and columns.
  • A two-dimensional array can emulate a database table in which each row represents a record and each column represents a field.
  • A subprogram is a named, reusable section of code; a function returns a value, whereas a procedure performs a task without necessarily returning a value.
  • A local variable or constant is accessible only within its subprogram, whereas a global variable or constant can be accessed from multiple parts of the program.
  • Data, including arrays, can be passed into subprograms as parameters, and functions can return results, including arrays where the language supports this.
  • An SQL query uses SELECT to identify the fields to retrieve, FROM to identify the table, and WHERE to filter records that meet a condition.

rocket_launchYou must be able to

  • Write programs that use variables, constants, input, output and assignment with meaningful identifiers and suitable values.
  • Construct algorithms using sequence, selection, count-controlled loops and condition-controlled loops so that control flow matches the problem requirements.
  • Form arithmetic, comparison and Boolean expressions using the correct operators and precedence to calculate values and test conditions.
  • Choose suitable integer, real, Boolean, character and string data types for a scenario, and cast values when a different type is temporarily required.
  • Manipulate strings by concatenating values and slicing strings at the required positions.
  • Create, populate, traverse and update one-dimensional and two-dimensional arrays using valid indices and appropriate loops.
  • Open, read, write and close files in the correct order, processing stored records accurately.
  • Decompose a program into functions and procedures, passing required parameters and return values while using local and global data appropriately.
  • Write SQL queries using SELECT, FROM and WHERE to retrieve specified fields and filter records by given criteria.
  • Generate and use random numbers within an appropriate range, such as for simulations, games or random selections.


Revision Quiz

trophy Congratulations! You have completed the quiz.