Programming concepts Flashcards
What does a variable do?
Holds values that can be modified when the program is executed
What does a constant do?
Holds values that remain unchanged when a program is executed
How do you assign a variable?
Declare the name and data type, then assign a value
What are the three main steps to using variables?
Declaration, Assignment, and Initialisation
What is declaration?
Creating space in memory for a variable or constant
What is assignment?
Setting the contents of the memory space to a value
What is initialisation?
Setting the value of a variable before any processing takes place
Name the advantages of using constants
You can use the same identifier throughout a program which keeps the program code consistent- making it easy to debug and read, if errors occur changes only need to be made at one point- the initialising of the constant
Define an identifier
A name given to any variable, constant, subroutine, or class
Why are meaningful identifiers important?
So the purpose of the subroutine is clear to anyone reading your code
What are definite loops and how are they implemented? give an example
A set of instructions repeated a certain number of times, implemented by count-controlled loops e.g. for
What are indefinite loops and how are they implemented? give an example
A set of instructions that are repeated until a condition is met, implemented by condition control loops e.g. while
When does a while loop check its condition?
At the start of each iteration until the condition is met
When does a repeat until loop check its condition?
At the end of each iteration until the condition is met
What is nested iteration?
When a loop is inside another loop
How does nested iteration work?
The inner loop will be executed for all the iterations of the outer loop
Define sequence
A series of instructions that a program executes in order, one after another
How does selection differ from sequence?
Selection executes a program based on a condition
What is nested selection used for?
Implementing branching logic
What is branching logic?
If a condition of the main selection block evaluates to true then it leads to sub-conditions which are included inside the main condition
What are operands?
The values in calculations to which arithmetic operators are applied
`What does DIV do?
Returns ONLY the whole number part of a division, the fractional part is dismissed
What does MOD do?
Returns ONLY the remainder of a division
What does Round() do?
Rounds up the result of an operation