472,127 Members | 1,884 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 software developers and data experts.

Difference between parameter and argument

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
6 6073
weaknessforcats
9,208 Expert Mod 8TB
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
donbock
2,425 Expert 2GB
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
Sherin
77 64KB

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.  
Jul 29 '20 #4
Naheedmir
62 32bit
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.
Jul 31 '20 #5
AjayGohil
83 64KB
Hey,

A parameter is a named variable passed into a function. ... 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

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.

for more information and Example refer following site:

https://www.geeksforgeeks.org/differ...with-examples/
Sep 2 '20 #6
sarbjitgrewal
19 16bit
Yeah, it's confusing for some beginners. Don't worry. I will help you out! A Parameter is a named variable passed into a function definition, whereas arguments are the real values passed to the function.
Sep 4 '20 #7

Post your reply

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

Similar topics

6 posts views Thread by Frans Englich | last post: by
14 posts views Thread by Dan | last post: by
2 posts views Thread by Mike Copeland | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.