RGM PL5
RGM PL5
They affect performance, memory usage, and wheather changes in the called function
affect the original data
Types of Parameter Transmission Schemes
- Pass by value:-
Description:- A copy of the variable is passed to the function. The original variable
remains. Unaffected.
Example
int main() 2
int y = 5;
increment (Y):
Print f (“%d”, Y); //
Output: 5
Return 0;
2. Pass by Reference=
Example-
C++
Int main() {
Int y = 5;
Increment (Y);
Description: A copy of the variable is passed and after the function executes, the result
is copied back to the original variable
Advantage: Combines the benefits of value and reference passing
Example (Pseudocode)
Pseudocode
Y = 10;
pass by Result :-
Description:- Only the final result of the parameter is passed back to the caller. No
initial value is sent to the function.
Advantages Useful for output only variables Disadvantages Undefined behaviour if the
variable is used before the function ends.
Pseudocode
Procedure assign-result(x)
X = 20;
Assign-result (y);
Pass by Name
Pseudocode
Procedure examp(x)
Print (x+x);
Pass by Reference –
Sometimes
Moderate
Pass by Result
Moderate
Pass by Name
Depends on usage
Conclusion:-
The choice of Parameter. Dep ends Safety, transmission scheme on factors like
performance, and ease of debugging
Modern programming languages often use pass by value with or pass by reference,
variations (eg. Python’s reference
Sometimes
Moderate
Pass by Result
Moderate
Output only parameters.
Pass by Name
Depends on usage
Conclusion:-
The choice of Parameter. Dep ends Safety, transmission scheme on factors like
performance, and ease of debugging
Modern programming languages often use pass by value with or pass by reference,
variations (eg. Python’s reference model