Note the difference between parameters and arguments: Function parameters are the names listed in the function's definition. Function arguments are the real values passed to the function. Parameters are initialized to the values of the arguments supplied.
In simpler terms, the argument is the actual value supplied to a function, whereas the parameter is the variable inside the definition of the function. We can say that a parameter is a type that appears in function definitions, while an argument is an instance that appears in function calls.
A parameter is the variable listed inside the parentheses in the function definition. An argument is the value that are sent to the function when it is called.
Argument is often used in the sense of actual argument vs. formal parameter.
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. For example, I have also heard actual parameter etc.
So here, x
and y
would be formal parameters:
int foo(int x, int y) {
...
}
Whereas here, in the function call, 5 and z
are the actual arguments:
foo(5, z);
Generally, the parameters are what are used inside the function and the arguments are the values passed when the function is called. (Unless you take the opposite view — Wikipedia mentions alternative conventions when discussing parameters and arguments).
double sqrt(double x)
{
...
return x;
}
void other(void)
{
double two = sqrt(2.0);
}
Under my thesis, x is the parameter to sqrt()
and 2.0 is the argument.
The terms are often used at least somewhat interchangeably.
They are often used interchangeably in text, but in most standards the distinction is that an argument is an expression passed to a function, where a parameter is a reference declared in a function declaration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With