What are the 3 programming constructs?
Give an example of each programming construct
What is recursion?
a programming subroutine where a section of code calls itself until a base case is met
What are the 3 conditions for a recursive statement?
Which is more efficient in terms of memory usage (recursion/iteration) and why?
What is a global variable?
a variable that is:
- “typically” declared at at the top of a program outside of any subroutine
- accessible throughout the program
- created when the program starts
- destroyed when the program ends
What is a local variable?
a variable that is:
- declared inside a subroutine
- only accessible by that subroutine
- created when the subroutine is called
- destroyed when the subroutine ends
Why is use of global variables generally considered poor programming practice?
excessive, unnecessary use of global variables can make programs hard to test, debug and maintain
What is modularity?
What is a procedure?
a subroutine that takes in zero, one or more parameters and performs a set task
What is a function?
a subroutine that takes in zero, one or more parameters and performs a set task and returns a value
What are the 2 methods of passing data into a subroutine?
What does passing a parameter by reference mean?
passing the address or pointer of the required value into a procedure
What does passing a parameter by value mean?
creating a temporary local copy of the actual value of a variable and passing it into the procedure