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.
Difference Between Argument and Parameter in CArgument is the actual value of this variable that gets passed to function. Parameter is variable in the declaration of the function.
A parameter is a variable in a method definition. When a method is called, the arguments are the data you pass into the method's parameters.
public void MyMethod(string myParam) { }
...
string myArg1 = "this is my argument";
myClass.MyMethod(myArg1);
Parameter is variable in the declaration of function.
Argument is the actual value of this variable that gets passed to function.
Simple:
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.
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