Unit 1 - Fundamentals of programming Flashcards
What is an algorithm?
A sequence of instructions that can be followed to solve a problem.
What can relational operators be used for?
To compare values within the expression
What are the three types of iteration?
Indefinite iteration with the condition tested at the start of the loop. (While)
Indefinite iteration with the condition tested at the end of the loop.
Definite iteration where the loop is performed a given number of times. (For loop)
What is a subroutine?
A set of instructions with a name
What is a function?
A subroutine that returns one or more values.
What are library subroutines?
Pre-defined subroutines.
Where do parameters appear?
In subroutine definitions. They are part of the subroutine definition.
Where do arguments appear?
In subroutine calls. They may vary from call to call.
What is a local variable?
It can only be used in that subroutine, they are created once a method is entered and cleared once the method is exited.
What is a global variable?
it is defined in the main program and can be used in any subroutine called from the main program.
What is the scope of variables?
The scope of a local variable is the subroutine which it is declared. The variable does not exist outside the subroutine.
What are advantages of local variables?
The subroutines will be independent of a particular program and can be re-used in different programs.
There is no chance of accidentally changing a variable in the main program that is used in a subroutine or vice versa.
Keep your subroutines self-contained!
Pass as arguments any values that are needed.
What is modular programming?
Means breaking down a major task into smaller subtasks.
What are some advantages of modular programming?
Large programs are broken down into subtasks that are easier to program and manage.
Each module can be individually tested
Modules can be re-used several times in a program.
Large programs are much easier to debug and maintain.
Programs are more easily and quickly written.
What does a file consist of?
A number of records.