What's the difference between an argument and a parameter?

后端 未结 30 1876
北恋
北恋 2020-11-22 01:08

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

30条回答
  •  既然无缘
    2020-11-22 01:44

    They both dont have much difference in usage in C, both the terms are used in practice. Mostly arguments are often used with functions. The value passed with the function calling statement is called the argument, And the parameter would be the variable which copies the value in the function definition (called as formal parameter).

    int main ()
    {
       /* local variable definition */
       int a = 100;
       int b = 200;
       int ret;
    
       /* calling a function to get max value */
       ret = max(a, b);
    
       printf( "Max value is : %d\n", ret );
    
       return 0;
    }
    
    /* function returning the max between two numbers */
    int max(int num1, int num2) 
    {
       /* local variable declaration */
       int result;
    
       if (num1 > num2)
          result = num1;
       else
          result = num2;
    
       return result; 
    }
    

    In the above code num1 and num2 are formal parameters and a and b are actual arguments.

提交回复
热议问题