2.2 - Programming Fundamentals Flashcards
What are the three programming constructs?
- Sequence
- Selection
- Iteration
What is sequencing?
Structuring code into a logical, sequential order
What is selection?
Decision making using if statements
What is iteration?
Repeating code using for or while loops
What are variables used for?
Assigning a data value (E.G: “Emily”) to an identifier (E.G: First_Name)
What is a constant?
A variable that doesn’t change whilst the program is running
What is a subroutine
- Named out of line blocks of code
- You must call them to execute them
- Functions must have a return value and are left internally
What are local variables?
Variables declared within a specific subroutine that can only be used within that subroutine
What are the advantages of using local variables?
- Saves memory
- Easier to debug local variables
- You can reuse subroutines with local variables in other programs
What are global variables?
Variables that can be used at any point within the whole program
What are the advantages of using global variables?
- Can be used anywhere in the program
- Makes maintenance easier
- Can be used for constants
What are the most common arithmetic operators?
- Add (+)
- Subtract (-)
- Multiply (*)
- Divide (/)
What is modulo division (AKA modulus)?
Reveals the remainder from the last whole number, E.G:
9 MOD 4 = 1 (4 goes into 9 twice (8) with a remainder of 1)
Operator: MOD or %
What is integer division (AKA quotient)?
Reveals the whole number of times a number can be divided into another number, E.G:
9 DIV = 2 (4 goes into 9 fully, twice)
Operator: DIV or //
What are logical operators?
TRUE or FALSE values (Boolean), E.G: AND, OR or NOT