Exam code: 9618
1/240Still learning
Know0
Define sub program.
A sub program is a sequence of instructions that performs a specific task or set of tasks.

Join for free to unlock a full flashcard set, track what you know,
and turn revision into real progress.
Where are procedures and functions defined?
At the start of the code.
Name three uses of a sub program.
To avoid duplicating code so it can be reused, to improve the readability and maintainability of code, and to perform calculations, retrieve data or make decisions based on input.
Was this flashcard helpful?
Define sub program.
A sub program is a sequence of instructions that performs a specific task or set of tasks.
Where are procedures and functions defined?
At the start of the code.
Name three uses of a sub program.
To avoid duplicating code so it can be reused, to improve the readability and maintainability of code, and to perform calculations, retrieve data or make decisions based on input.
Define parameter.
A parameter is a variable or value passed into a sub program, written in brackets after the name of the sub program.
To use a sub program you it from the main program.
To use a sub program you call it from the main program.
Which keyword defines a procedure in pseudocode?
PROCEDURE, closed with ENDPROCEDURE.
How do you call a procedure?
With CALL <identifier>(), or CALL <identifier>(Value1, Value2, ...) if it takes parameters.
What must be true of the values passed when calling a procedure with parameters?
They must be of the correct data type and in the same sequence as the parameters in the definition.
In the GreetUser example, what parameter does the procedure take?
One parameter, Name, of type STRING.
Which keyword defines a function in pseudocode?
FUNCTION, closed with ENDFUNCTION.
What is the difference between a function and a procedure?
A function returns a value, whereas a procedure does not.
True or False?
A procedure returns a value to the code that called it.
False.
A function returns a value. A procedure does not.
Why do functions not use CALL?
Because they always return a value, so they are called within an expression instead.
What is the pseudocode syntax for a function that takes no parameters?
FUNCTION <identifier> RETURNS <data type>, then the statements, closed with ENDFUNCTION.
What is the pseudocode syntax for a function that takes parameters?
FUNCTION <identifier>(<param1>:<data type>, <param2>:<data type>...) RETURNS <data type>, then the statements, closed with ENDFUNCTION.
Which keyword sends a value back from a function?
RETURN
Can a sub program have more than one parameter?
Yes. Sub programs can have multiple parameters, separated by commas inside the brackets.
Define parameter passing.
Parameter passing is the method by which values or references are given to procedures or functions, so they can use or modify data during execution.
What does BYVAL do?
It passes a copy of the value, so the original variable is not changed.
What does BYREF do?
It passes the actual variable, so changes made inside the procedure affect the original.
BYREF passes a to the variable, so that it can be modified.
BYREF passes a reference to the variable, so that it can be modified.
Which parameter passing method is used if no keyword is given?
BYVAL is assumed.
True or False?
Functions should use BYREF parameters.
False.
Functions should not use BYREF parameters. Only procedures should.
In the Swap procedure, why can X be changed but not Y?
X is passed by reference, so it can be changed. Y is passed by value, so any change to it inside the procedure does not affect the original.
By signing up you agree to our Terms and Privacy Policy