By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,212 Members | 1,331 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,212 IT Pros & Developers. It's quick & easy.

Difference between parameter and argument

P: 16
Please tell me the difference between an argument and parameter...i was really confused in understanding the difference between these two.
May 26 '14 #1
Share this Question
Share on Google+
4 Replies


weaknessforcats
Expert Mod 5K+
P: 9,197
A parameter is a named value whereas an argument is just a value. For example:

Expand|Select|Wrap|Line Numbers
  1. int function(int x, char y);
Here int and char are parameters while x and y are arguments. The arguments can have any value. The parameter has to be an int.

Another example:

Expand|Select|Wrap|Line Numbers
  1. enum color = {RED, WHITE,BLUE};
  2.  
An enum list like this is a list of named integer values. RED, WHITE, and BLUE above are parameters with values 0,1, and 2. So of all the int values possible only 0,1 and 2 are valid. You use RED instead of 0, WHITE instead of 1, etc.
May 26 '14 #2

Expert 100+
P: 2,418
Excerpts from the 1999 C Standard (C99), Section 3 (Terms, definitions, and symbols)...

3.3 argument
actual argument
actual parameter (deprecated)
expression in the comma-separated list bounded by the parentheses in a function call expression, or a sequence of preprocessing tokens in the comma-separated list bounded by the parentheses in a function-like macro invocation.

3.15 parameter
formal parameter
formal argument (deprecated)
object declared as part of a function declaration or definition that acquires a value on entry to the function, or an identifier from the comma-separated list bounded by the parentheses immediately following the macro name in a function-like macro definition.
The difference between parameter and argument is subtle: use the term parameter when referring to the function declaration or function/macro definition; use the term argument when referring to function/macro invocations. The modifiers suggested by the definitions can help to keep them straight: actual argument versus formal parameter.

It looks like the terms were once interchangeable but that later versions of the Standard deprecated interchangeable use of the terms.
May 29 '14 #3

P: 33

Argument

An argument is referred to the values that are passed within a function when the function is called. These values are generally the source of the function that require the arguments during the process of execution. These values are assigned to the variables in the definition of the function that is called. The type of the values passed in the function is the same as that of the variables defined in the function definition. These are also called Actual arguments or Actual Parameters.

Example


Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h> 
  2.  
  3. int sum(int a, int b) 
  4.     return a + b; 
  5.  
  6. int main() 
  7.     int num1 = 10, num2 = 20, res; 
  8.  
  9.     res = sum(num1, num2); 
  10.  
  11.     printf("The summation is %d", res); 
  12.     return 0; 
Parameters

The parameter is referred to as the variables that are defined during a function declaration or definition. These variables are used to receive the arguments that are passed during a function call. These parameters within the function prototype are used during the execution of the function for which it is defined. These are also called Formal arguments or Formal Parameters.

Example

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h> 
  2.  
  3. int Mult(int a, int b) 
  4.     return a * b; 
  5.  
  6. int main() 
  7.     int num1 = 10, num2 = 20, res; 
  8.  
  9.     res = Mult(num1, num2); 
  10.  
  11.     printf("The multiplication is %d", res); 
  12.     return 0; 
  13.  
5 Days Ago #4

P: 15
The term parameter is mostly used to recognize the placeholders in the method signature, whereas the term argument is the exact values that you pass into the method.
3 Days Ago #5

Post your reply

Sign in to post your reply or Sign up for a free account.