24.8k views
5 votes
What are formal parameters ?

Select one:
a. Formal parameters are found in the subroutine definition. The values of the actual parameters are assigned to the formal parameters before the body of the subroutine is executed.
b. Formal parameters are used only with GUI (graphical user interface).
c. Formal parameters are the parameters found in subroutine call statements,
when the subroutine is called.
d. Formal parameters describe parameters used by the main program only.

User Tonechas
by
7.8k points

1 Answer

3 votes

Final answer:

Formal parameters are defined in a subroutine, function, or method to receive data when it is called, with the correct option being (a). They define the type and name of data that the subroutine can process, and actual parameter values are assigned to them when the subroutine is executed.

Step-by-step explanation:

Formal parameters are the parameters listed in the definition of a subroutine, function, or method. They are placeholders that define the type and the name of the data that the subroutine can accept. When a subroutine is called, the actual data or arguments that are passed to it are known as actual parameters or arguments.

The values of the actual parameters are assigned to the corresponding formal parameters before the subroutine's body is executed.

The correct answer to the question is: a. Formal parameters are found in the subroutine definition. The values of the actual parameters are assigned to the formal parameters before the body of the subroutine is executed.

Example of formal parameters:

Consider a simple function definition in a programming language like Python:

def add_numbers(a, b): # a and b are formal parameters
return a + b

Here, a and b are formal parameters that will receive values when the function is called, for example, add_numbers(5, 3).

User Poddroid
by
7.4k points