Signed up recently but had issues with the confirmation email?
Click Forgot password and follow the reset steps. You can choose the same password you used when you signed up. This should then provide access.
Remember to check Spam and Junk. The email will be from auth@progressbytes.co.uk.
Modularity, functions and procedures, parameter passing by value and by reference.
2.2.1 Programming Techniques
Practise exam questionsProgramming Techniques — Note 4 of 6
Candidates need to understand what is meant by modular code and how it is produced using functions and procedures, including the differences between them. Candidates need to understand the purpose of parameters and the difference between passing by value and by reference, recommending which to use for a given situation. Candidates need to be able to read, trace and write code that uses functions, procedures and parameters.
Modular programs are built from subroutines, each carrying out one task. Functions return a value; procedures do not. Parameters can be passed by value (a copy) or by reference (the original), which affects whether the subroutine can change the caller's data.
byVal and byRef are used.procedure update(x:byVal, y:byRef)
x = x + 10
y = y + 10
endprocedure
a = 1
b = 1
update(a, b)
print(a) // 1 (only the copy changed)
print(b) // 11 (the original changed)Breaking a program into separate subroutines or modules, each performing one task, that can be written and tested independently.
A subroutine that returns a value to the point where it was called.
A subroutine that carries out a task but does not return a value.
A variable in the subroutine definition that receives a value (argument) when the subroutine is called.
A COPY of the argument is passed; changes inside the subroutine do not affect the original variable.
The ADDRESS of the original variable is passed; changes inside the subroutine DO affect the original variable.
swap(a, b)), or copying a large structure would waste memory.function isPrime(17)) when you need a call. A call is the name and arguments, e.g. found = isPrime(17); store or test the returned value, and test a Boolean directly (if found then), not against the string "True". When the question gives you a function, don't rewrite it: call it ONCE, store the result, and handle both outcomes. If the function changes data (e.g. adds an item to a list), calling it again to test the result makes that change twice.Past exam questions
Ready to test yourself?
Practise 2.2.1 questions