Programming Techniques- S11 Flashcards
Algorithm
is a set of rules or a sequence of steps specifying how to solve a problem.
Pseudocode
tool for developing algorithms, and is between English and program statements.
Indentation
Statements shifted to the right that are contained within a block
Initialisation
setting variables to appropriate values at the beginning of a program to ensure there is not a value already assigned to it.
Variables
A name in memory used to store a value with can change during execution.
Constant Variables
a value that cannot be altered by the program during normal execution. E.g pi=3.14159265
Why are Constant Variables used
to make the programs easier to understand, easier to change the value of variable throughout the program and to make sure a programmer doesn’t accidentally change its value.`
Give Data Types
Integer, String, Float, Boolean, Character, Date
Sequences
Two or more statements following each other.
Selection
When there is a condition that needs to be met in order for certain statements to be executed.
Pseudocode for a switch case
switch entry: case “A”: print(“You selected A”) case “B”:1 print(“You selected B”) default: print(“Unrecognised selection”) endswitch
Iteration
An iteration is a repetition so a loop.
Give examples of Iteration
While… End While
For count… Next count
for i… next i
Repeat… until
Subroutines
a named block of code which performs a specific task within the program.
Subroutines are good to use because
Easier to understand Easier to debug Can be reused Each module can be tested independently Work is divided between team, so saves time Each member can work on their expertise
Function
A named subroutine that returns a value, called inline, and performs a specific task.
Procedure
A named subroutine that performs a specific task but does not return a value.
parameter by reference
a parameter can be changed in the subroutine and will then change the value of variable which has been passed in. (only used in procedures)
parameter by value
is when the value is passed to subroutine and is treated as a local variable. Changing the parameter inside the subroutine does not affect the value outside the subroutine.
Global variable
are used in the main program and can be used anywhere in the program including within subroutines.
Local variable
are variables used in a subroutine and are self-contained.
Modular design/programming
When the program is divided into separate self-contained modules or tasks, which can be written and tested individually. Modules can be subdivided further into smaller modules.
Advantages of modular design
Easy to understand Can be reused Reduced development time Modules can be shared between programmers Easier to maintain/debug
IDE (Integrated Development Environment)
A set of tools put all in one program and helps you write code more easily.