Difference between parameter and argument

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • saiavinashiitr
    New Member
    • Mar 2014
    • 16

    #1

    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.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    A parameter is a named value whereas an argument is just a value. For example:

    Code:
    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:

    Code:
    enum color = {RED, WHITE,BLUE};
    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.

    Comment

    • donbock
      Recognized Expert Top Contributor
      • Mar 2008
      • 2427

      #3
      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.

      Comment

      • Sherin
        New Member
        • Jan 2020
        • 77

        #4

        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


        Code:
        #include <stdio.h> 
        
        int sum(int a, int b) 
        { 
        	return a + b; 
        } 
        
        int main() 
        { 
        	int num1 = 10, num2 = 20, res; 
        
        	res = sum(num1, num2); 
        
        	printf("The summation is %d", res); 
        	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

        Code:
        #include <stdio.h> 
        
        int Mult(int a, int b) 
        { 
        	return a * b; 
        } 
        
        int main() 
        { 
        	int num1 = 10, num2 = 20, res; 
         
        	res = Mult(num1, num2); 
        
        	printf("The multiplication is %d", res); 
        	return 0; 
        }

        Comment

        • Naheedmir
          New Member
          • Jul 2020
          • 62

          #5
          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.

          Comment

          • AjayGohil
            New Member
            • Apr 2019
            • 83

            #6
            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:

            Comment

            • sarbjitgrewal
              New Member
              • Sep 2020
              • 19

              #7
              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.

              Comment

              Working...