Data Types, Data Structures, Scope And Parameters Flashcards
What is a record?
A collection of data stored for one item, person or event. A record may contain data items of different data types
What is a sequential file?
Data may be read from or written to external files. Data items are read/written in sequence. This is useful if the data is to be kept after program execution.
What is a subroutine?
A block of code that has been separated from the main program, they usually perform a single task or action. The subroutine is called by another part of the program when required, the lines in the subroutine are then executed and the program continues from the call command.
What is modular programming?
Aims to split a program into as many self-contained subroutines as possible. Modularity improves the maintainability of a program as it is possible to re write a single module without changes impacting on the rest of the program.
What is the scope of a variable?
The area of a program in which the variable can be used. A variable may be declared as either global - has global scope - so can be used at any point in the code, - or local . A local variable can only be used - has scope - inside the subprogram where it is defined.
What is an advantage of a local variable?
The value of a local variable can only be altered within the one part of the program in which it exists - has scope - usually a subroutine.
Describe the difference between a data type and a data structure
A data type is used to store a single variable. A data structure is used to store multiple items of data.
What is an array?
A type of data structure with numbered elements, each of element stores an item of the same data type
What is a procedure?
A subroutine which performs a task that is contained completely within its code.
What is a method?
A subroutine used in object-oriented programming that defines the behaviour of an object.
What is a function?
A subroutine with code that calculates a value which it returns to the main program.
What does passing a parameter by value mean?
If a variable is passed by value, a copy of the data is made within the subroutine. Any changes made to the passed data do not affect the original data.
What does parameter passing by reference mean?
If a variable is passed by reference, the original data is used inside the subroutine - no copy is made. So the global / passed value gets modified within the subroutine.
What is a formal parameter?
This refers to the variable name used on the subroutine definition line. Formal parameters only have a value when the subroutine is called. Example: procedure calc_wages hours rate
What is an actual parameter?
This refers to the actual data values that are passed into the subroutine at run time, when the subroutine is called e.g. calc_wages 40 7.50