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)
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
What does casting allow?
- numbers to be manipulated as strings
- inputs that are strings to become numbers
What is an array?
A variable which contains more than one data item e.g. storing a list of names
What does contiguous mean?
All the data is stored together, one element after another
What does index start with?
It starts with 0
What is append?
Asserting a new item into new location at end of array using an index
How is the element (particular data item) found?
Using the index
Are arrays single and multiple dimensions?
They are both
What is a flowchart?
A method of representing sequences of steps in an algorithm in form of a diagram
What is pseuodocode?
Alternative text-based way of representing sequence of steps in an algorithm
Advantages of using sub programs
Easier to write/read and debug and creates reusable components
What are sub-routines?
Larger programs developed as a set of sub-programs
What do functions do?
Return values and create reusable program components
What do procedures do?
Create a modular structure to a program making it easier to read