When verbally talking about methods, I\'m never sure whether to use the word argument or parameter or something else. Either way the other people know what
Parameter is variable in the declaration of function.
Argument is the actual value of this variable that gets passed to function.
In editing, I'm often put off at how people forget: structure languages are based on natural languages.
A "parameter" is a placeholder. They set the response format, in spoken language. By definition, it's party to the call, limiting the response.
An "argument" is a position that is being considered. You argue your opinion: you consider an argument.
The thematic role of an argument is agent. The thematic role of parameter is recipient.
Think of the argument as the male part, making the parameter the female part. The argument goes into the parameter.
A parameter is usually used in definitions. An argument is usually used in invocations.
Finish the sentence to make it less dissonant.
(A) Speaking of a definition:
(B) Speaking of an invocation:
(A)
(B)
As you can imagine, after answering: in spoken language, these words will sometimes produce identical responses!
So, as a rule:
Usually if someone wants parameter information, they want to know more about the type, the variable name, etc. They may become confused if you only give example arguments.
The formal parameters for a function are listed in the function declaration and are used in the body of the function definition. A formal parameter (of any sort) is a kind of blank or placeholder that is filled in with something when the function is called.
An argument is something that is used to fill in a formal parameter. When you write down a function call, the arguments are listed in parentheses after the function name. When the function call is executed, the arguments are plugged in for the formal parameters.
The terms call-by-value and call-by-reference refer to the mechanism that is used in the plugging-in process. In the call-by-value method only the value of the argument is used. In this call-by-value mechanism, the formal parameter is a local variable that is initialized to the value of the corresponding argument. In the call-by-reference mechanism the argument is a variable and the entire variable is used. In the call- by-reference mechanism the argument variable is substituted for the formal parameter so that any change that is made to the formal parameter is actually made to the argument variable.
The use of the terms parameters and arguments have been misused somewhat among programmers and even authors. When dealing with methods, the term parameter is used to identify the placeholders in the method signature, whereas the term arguments are the actual values that you pass in to the method.
MCSD Cerfification Toolkit (Exam 70-483) Programming in C#, 1st edition, Wrox, 2013
Real-world case scenario
// Define a method with two parameters
int Sum(int num1, int num2)
{
return num1 + num2;
}
// Call the method using two arguments
var ret = Sum(2, 3);
Parameters are the variables received by a function.Hence they are visible in function declaration.They contain the variable name with their data type. Arguments are actual values which are passed to another function. thats why we can see them in function call. They are just values without their datatype
There is already a Wikipedia entry on the subject (see Parameter) that defines and distinguishes the terms parameter and argument. In short, a parameter is part of the function/procedure/method signature and an argument is the actual value supplied at run-time and/or call-site for the parameter.
The Wikipedia article also states that the two terms are often used synonymously (especially when reasoning about code informally):
Although parameters are also commonly referred to as arguments, arguments are more properly thought of as the actual values or references assigned to the parameter variables when the subroutine is called at runtime.
Given the following example function in C that adds two integers, x
and y
would be referred to as its parameters:
int add(int x, int y) {
return x + y;
}
At a call-site using add
, such as the example shown below, 123 and 456 would be referred to as the arguments of the call.
int result = add(123, 456);
Also, some language specifications (or formal documentation) choose to use parameter or argument exclusively and use adjectives like formal and actual instead to disambiguate between the two cases. For example, C/C++ documentation often refers to function parameters as formal arguments and function call arguments as actual arguments. For an example, see “Formal and Actual Arguments” in the Visual C++ Language Reference.