Actual And Formal Arguments In C++
Actual And Formal Arguments
The
arguments may be classified under two groups, actual and formal arguments.
Fig: Actual and Formal Arguments in c++
(a) Actual arguments
An
actual argument is a variable or an expression contained in a function call
that replaces the formal parameter which is a part of the function declaration.
Sometimes,
a function may be called by a portion of a program with some parameters and
these parameters are known as the actual arguments.
For example
#include <iostream.h>
void
main ()
{
int
x,y;
void
output (int x, int y) ; / / function declaration
output
(x,y) ; / / x and y are the actual arguments
}
(b)
Formal arguments
Formal arguments are the parameters presents in a function definition which may also be called as dummy arguments or the parametric variables. When the function is invoked, the formal parameters are replaced by the actual parameters.
For example
#include
<iostream.h>
void
main ()
{
int
x,y;
void
output (int x, int y) ;
output
(x,y) ;
}
void
output (int a, int b) / / formal or dummy arguments
{
/
/body of the function
}
No comments:
Post a Comment