2.2 Programming Fundamentals Flashcards
What is a variable?
A value that can change whilst the program is running. It is simply an address in memory e.g. an integer, character string, real(float) or Boolean.
What is a constant?
A value which remains fixed as it does not change while the program is running, and is assigned when the program is running.
What is an assignment?
When we give, or supply a value to a variable or constant. It is performed with the ‘=’ symbol.
What is an operator?
Symbols used to perform operations on variables and values
What is an output?
Data generated by the computer and displayed to the user.
What is an input?
A value is read from an input device e.g. Keyboard
What is casting?
Converting a variable from one data type to another e.g. integer to a string
Advantages of constants:
- Easier to read as they are usually declared and assigned at top of the program
- Less chance of errors
- Makes program run more quickly if used instead of variables
Why is casting needed?
- Inputs from keyboards are always characters. Multiple characters are called a string
- Integers require less bits of memory than numbers with a decimal part (real numbers)
Data types for constants and variables
Three Programming Constructs
Sequence, Selection, Iteration.
What is sequence?
Executing one instruction after another
What is selection?
Selection is a program branching depending on a condition (if, else, elseif)
What is branching?
A construct that allows the program to end up going in a number of various directions depending on the outcome of a condition
What is iteration?
Iteration, sometimes called looping, is repeating sections of code until a condition is met. (for loop, while loops)