2.2 Programming Fundamentals Flashcards
(38 cards)
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)
What are while loops?
While loops, known as condition controlled loops are used when the number of iterations is not known because the variable used to determine when the iteration end is changing within the iteration itself.
What are DO..UNTIL loops?
An alternative to WHILE where the code is executed at least once before the condition is checked
What does the Arithmetic Logic Unit perform?
Arithmetic comparisons, logical comparisons, binary shifts
Why is a Boolean operator called Boolean Expression?
The expression equates or evaluates to either true or false
What does concatenate mean ?
Join together
How do we concatenate numbers?
In order to concatenate them, and not simply add them they need to be stored as a string data type
How can you perform arithmetic operations on values?
Converts string data types back into integers or any other data types to perform arithmetic operations on values
What is a value entered from the keyboard inputted as?
Characters
Why is casting necessary?
It is so subproblems receive data in a format they are expecting