Programming fundamentals

Cards (23)

  • Variable
    Named memory address that holds a value
  • The value assigned to a constant cannot be changed whilst the program is running
  • Constants are useful because they are declared and assigned once
  • Global variable
    A variable that can be accessed and changed throughout the program
  • Local variables
    A variable that is confined to a loop or subprogram
  • Three basic programming constructs
    • Sequence
    • Selection
    • Iteration
  • Sequence
    The order in which instructions occur and are processed
  • Selection
    A decision within a computer program when the program decides to move on based on the results of an event
  • Iteration
    The repeated execution of a section of code when a program is running
  • Two types of iteration:
    • Count controlled iteration
    • Condition controlled iteration
  • Count controlled iteration repeatedly executes a section of code a fixed number of predetermined times, using the statements 'for' and 'next'
  • Using count controlled iteration can lead to fewer programming errors and more flexible programs
  • Condition controlled iteration repeatedly executes a section of code until a condition is met, or no longer met
  • Two times of condition controlled iteration:
    • While statements (uses the statements while and endwhile)
    • Repeat loops (uses the statements repeat and until)
  • With a while loop, the code within the iteration may never be executed. With a repeat loop, the code is always executed atleast once
  • Infinite loop
    A loop that repeats forever
  • Nesting
    Including one programming construct within another
  • Three types of operator:
    • Mathematical operators
    • Comparison operators
    • Logical operators
  • Multiplication
    *
  • Division
    /
  • Integer division
    DIV
  • Remainder
    MOD
  • Exponentiation
    ^