Difference between parameter and argument

Language AgnosticParametersArgumentsTerminology

Language Agnostic Problem Overview


Is there a difference between a "parameter" and an "argument", or are they simply synonyms?

Language Agnostic Solutions


Solution 1 - Language Agnostic

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);

Solution 2 - Language Agnostic

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.

Solution 3 - Language Agnostic

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.

Solution 4 - Language Agnostic

Arguments and parameters are different in that parameters are used to different values in the program and The arguments are passed the same value in the program so they are used in c++. But no difference in c. It is the same for arguments and parameters in c.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionChunky ChunkView Question on Stackoverflow
Solution 1 - Language AgnosticdanleiView Answer on Stackoverflow
Solution 2 - Language AgnosticJonathan LefflerView Answer on Stackoverflow
Solution 3 - Language AgnosticnasView Answer on Stackoverflow
Solution 4 - Language AgnosticSuranan AshwiniView Answer on Stackoverflow