Section 1 Flashcards
Standard algorithms
- Input validation
- Running total in loop
- Traversing a 1D array
Predefined Functions
- Round:
Rounds numbers to certain no. of sig figs
eg SET size TO ROUND (measurement, 2) - Length:
Returns the number of characters present in a value held in a variable
eg SET numberOfCharacters TO LENGTH (firstname) - Random:
Returns random value in given parameters
eg SET bonusBall TO RANDOM(1, 59)
Storing real numbers
Stored using mantissa and exponent
mantissa x base ^ exponent
Types of errors
- Syntax [eg misspelling]
- Logic [eg code out of order]
- Execution/run time [eg dividing by 0]
Factors affecting readability
- Whitespace
- Meaningful variable names
- Internal commentary
Logical operators
- AND
- OR
- NOT
Storing vector graphics
Stored as a series of objects with a list of attributes
objects: square, ellipse
attributes: x- and y- coordinates, fill colour, length
Storing bitmapped graphics
Stored as a grid of pixels, each with it’s own unique binary code
Types of loops
conditional: keeps repeating until a condition is met.
eg while loops
unconditional/fixed: repeats a set number of times.
eg for loops
Number of bits for an ASCII string
Each character is 1 byte (8 bits)
Compiler
- translates source code into ‘object code’
- compiler is only held in RAM for the time that it takes to translate source code into object code
- translates lines one after the other but does not execute a line immediately after translation
- once created, object code can run independently of development environment and translator software
- if the object code file contains errors, the program will crash or cause unexpected output. Programmers must revisit source code, identify and correct errors and recompile
- used on finished, working programs
Interpreter
- each line of source code is directly translated to machine code one at a time
- each line of code is executed as soon as it is translated
- interpreter software is present in main memory during each execution of program and execution of every line
- execution will stop immediately if the interpreter translates a line of source code that results in an error, and user will be notified
- used on unfinished programs
Concatenation
The operation of joining character strings end-to-end
Iteration
Returning to previous stages of the development process
Methods to save energy
- settings on monitors
- power down settings (eg standby)
- leaving computers on standby