Flowgorithm Pass By Reference Example
Flowgorithm Pass By Reference Example
Parameter Passing is a mechanism used to pass parameters to a Flowgorithm function/procedure. They are several methods to pass the parameters. The most common methods are as follows:
- Pass By Value
- Pass By Reference
Pass by value example: Flowgorithm Pass By Value Example
Pass By Reference
In this method, we pass the address of the memory location (memory reference) of the actual parameter. So, this method allows the function or procedure to change the value of a variable that is passed.
Example
Let’s look at a simple example to understand the concept. In this example, we will pass an array using the pass by reference to the procedure.
Let’s design a simple procedure that increments the array of elements by ten. Let’s call the procedure name as : IncrementByTen()
Main Flowchart
The Main flowchart declares an array variable. arr is the array variable of size two. Populates the array elements with 10, and 20 values respectively.
We will pass this variable to the procedure in the procedure call statement. The array will be passed by reference to the procedure. The base address of the array will be used.
Procedure Flowchart
The arrayParam is the function parameter of the function IncrementByTen(). The procedure increments the elements by 10.
Note that the breakpoints in the procedure are added for demo purposes.
Before procedure call
The call stack and the activation record before the procedure entry point.
After procedure call
We can notice that the changes made to the procedure local variable side effects reflect on the array variable in the Main flowchart.
—
Flowgorithm Tutorials
Flowgorithm flowchart tutorials on this website:
https://www.testingdocs.com/flowgorithm-flowchart-tutorial/