Return to site

Difference Between Actual Parameter And Formal Parameter

broken image


Difference

A parameter is an optional list of parameters that you define both pass information into the procedure and send information out of procedure back to the calling program. Parameter is also known as argument. When you define a parameter, you also specify the way in which it can be used. There are three different modes of parameter or argument.

1. Actual Parameters :
The arguments that are passed in a function call are called actual arguments. These arguments are defined in the calling function. These are the variables or expressions referenced in the parameter list of a subprogram call. There is no need to specify datatype in actual parameter.

Example :

Difference Between Actual Parameter And Formal Parameters With Example

2. Formal Parameters :
These are the variables or expressions referenced in the parameter list of a subprogram specification. The datatype of the receiving value must be defined. The scope of formal arguments is local to the function definition in which they are used.

Example :

The formal parameter is what is given in the function declaration/definition/prototype, while the actual argument is what is passed when calling the function — an instance of a formal parameter, if you will. That being said, they are often used interchangeably, their exact use depending on different programming languages and their communities. The best that can be done is to look how each term is used in C# language specification (1.6.6.1 'Parameters'): Parameters are used to pass values or variable references to methods. The parameters of a method get their actual values from the arguments that are specified when the method is invoked. Actual parameters are the parameters which you specify when you call the Functions or Procedures. A formal parameter is a parameter which you specify when you define the function. The actual parameters are passed by the calling function. The formal parameters are in the called function. Actual Parameter is a parameter, which is used in function call statement to send the value from calling function to the called function. It is also known as Argument. Formal Parameter is a parameter, which is used in function header of the called function to receive the value from actual parameter. It is also known as Parameter.

Difference Between Actual Parameter And Formal Parameters With Suitable Example



Difference between Actual and Formal Parameters :

Actual ParametersFormal Parameters
When a function is called, the values (expressions) that are passed in the function call are called the arguments or actual parameters.The parameter used in function definition statement which contain data type on its time of declaration is called formal parameter.
These are the variables or expressions referenced in the parameter list of a subprogram call.These are the variables or expressions referenced in the parameter list of a subprogram specification.
Actual Parameters are the parameters which are in calling subprogram.Formal Parameters are the parameters which are in called subprogram.
There is no need to specify datatype in actual parameter.The datatype of the receiving value must be defined.
The parameters are written in function call are known as actual parameters.The parameters are written in function definition are known as formal parameters.
Actual Parameters can be constant values or variable names.Formal Parameters can be treated as local variables of a function in which they are used in the function header.

Recommended Posts:

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the 'Improve Article' button below.

Difference Between Actual Parameter And Formal Parameters In Java






broken image