Flashcards in Data Types, Data Structures, Scope And Parameters Deck (32):
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
What is the difference between a fixed loop and a conditional loop?
A fixed loop goes around a program a set number of times where as a conditional loop goes around until certain criteria are met.
When two or more strings/substrings are joined
What is a user defined function?
A user defined function is a function provided by the user to perform a specific task in order to generate a value.
Value held by Boolean data types
A true or false value
How is each element in a 1-D array identified?
An index value
A file that holds data in a set order
Can be opened, closed, read from or written to
What file operation is triggered if a non existent file name is opened?
Giving a value to a variable
What is meant by initialising a variable?
Assigning a starting value before the variable data is used or accessed
Records in software
A user defined data type which can store a group of data items of different types
Integers used to store
Positive or negative whole numbers
Strings used to store
one or more text characters
Real numbers used to store
Positive and negative whole numbers with decimal places
Boolean used to store
A true or false value
Why are data types declared before they are used?
Ensures that the required amount of memory is allocated to each variable during the programs execution
Used to store multiple items of data together