<u>Answer and explanation:</u>
There are many benefits of writing functions that use parameters and return. Some of them are:
1. Flexibility: With functions having parameters, several values of the parameters can be used at invocation time thereby making the application flexible. For example, given the following function in Java.
<em>public void showName(String name){</em>
<em> System.out.println("Your name is " + name);</em>
<em>}</em>
To call this method (function), the programmer could use various values for the name parameter used in the function like so:
showName("John");
showName("Doe");
If the function didn't have a parameter, it is possible it will only print a hardcoded name every time the function is called.
2. Scope Control: When a function is allowed to return a value, it helps to work around scope issues since variables declared within a function are limited to that function and do not exist outside the function. This means that the values of these variables cannot be used anywhere else outside the function in which they are being declared. However, if the function returns a value, the value can be used anywhere else in the program.
For example:
<em>public String getDouble(int x){</em>
<em> int y = x * 2</em>
<em> return y;</em>
<em>}</em>
The function above returns twice the value of the argument supplied to it. Since the integer variable y is declared within the function, it's value cannot be used outside the function. However, since the value is being returned by the function, it could be used anywhere the function is being called. Thanks to the return keyword.