Actual Argument and Formal Argument in C++
0 9790
Actual parameters are present in function calls whereas formal parameters are present in the function header of the definition. Formal parameters are known as the local or the parametric variables i.e. int y in the below example, that assigns values from the actual arguments when the function is called. Thus its value is replaced by the actual parameters
By default, the value of the Arguments is copied to the formal parameter during the calling time and the type of argument passing is pass-by-value.
Explanation:
As we all known earlier in the previous topic about the function declarations
i.e. void visual(int);
where int is known as the type of parameter and its name is optional. But when we are defining the same function as in the example
void visual(int y)
{
// code
}
Here, int y is known as a parameter. After this when we are calling the same function in main()
i.e
void visual(int y) // formal Argument
{
// code
}
int main()
{visual(200); // actual argument
}
Y can be used in the visual function. In many websites and book, the value of the function call is written an actual argument and the copied values in function definition are known as formal argument or parameter
Share:
Comments
Waiting for your comments