Site icon TestingDocs.com

Pass an Array to a Function in Flowchart

Overview

In this tutorial, we will design a flowchart with an Array and Function. We will pass an array to the function as a parameter. The function computes the sum of elements in the array and returns the sum to the main flowchart.

The flowchart uses multiple symbols and concepts. Some Useful Links:

Steps to create a flowchart

https://www.testingdocs.com/steps-to-create-flowgorithm-flowchart/

For loop in Flowgorithm

https://www.testingdocs.com/for-loop-statement-in-flowgorithm/

Arrays in Flowchart

https://www.testingdocs.com/arrays-in-flowgorithm-flowchart/

User defined Functions

https://www.testingdocs.com/user-defined-functions-in-flowgorithm/

Array parameter

Define a function SumArrayElements()

The function computes the sum of array elements. The function accepts an input parameter an Integer array and returns the sum of array elements.

The function name, function parameters and the return type when written together is called function prototype or function/method signature.

 

Click on the Add button to add function parameter. Give the function parameter name. Choose the type Integer and check the Array? checkbox. S0 that the function parameter is an Integer Array.

Function

 

The function uses a For loop to compute the sum of array elements.

The function returns the variable Integer Sum to the caller. Since, we call the function in the Main flowchart the function caller is the Main flowchart.

Main Flowchart

 

Notice that we are calling the function with the input Integer array.

SumArrayElements(A)

Sample Output

Run the Flowchart with Sample Data. The flowchart prompts the user to enter array elements.

Flowgorithm Tutorials Link:

https://www.testingdocs.com/flowgorithm-flowchart-tutorial/

Flowgorithm Website:

http://flowgorithm.org/

Exit mobile version