-3

I think some mentioned above are just synonyms but which ones? Also correct me if I'm wrong: In a function lets say the main function, the data between parenthesis is parameters/arguments?

2 Answers2

1

Passing values to a function has two points of view:

A function itself has a parameter (or formal parameter), when it is compiled. I. e. …

void f( int a )
{
  …
}

… has the (formal) parameter a.

When the function is called at run-time, there is a value that a represents. This is the argument (actual parameter):

f( 5 )

Here 5 is the argument (actual parameter).

So the call maps the argument/actual parameter to the formal parameter.

In C in some situations you can pass a variable number of arguments to a function. This is, if the function has an open parameter list:

f( int a, ... )

In many cases the first parameter is a format string that needs additional arguments. I. e.:

printf( "%d items", 5 );

In this case "%d items" is a format string (format argument) that tells the function to insert a string representation of the second argument ahead of " items".

But a variable number of arguments does not limit to format strings. I. e. the following examples are all (formally) valid calls:

f( int a, ... ) { … }

f( 5 );
f( 6, 2, 3 )

I think, dummy arguments/parameters has different meanings. It can be an parameter (and therefore an argument in a call) that isn't used inside the function. It can be an optional parameter, that gets a default value, if there is no argument for it in the call. (This concept does not exist in C, but in other programming languages.)

Amin Negm-Awad
  • 16,582
  • 3
  • 35
  • 50
0

A parameter is defined in the function definition.It is a placeholder for the arguments during function execution.

void printMessage(string message){  //message is a parameter. 

 }

An argument is a value passed to a function when the function is called.

printMessage("Hello World"); //"Hello World" is an argument.

Though someone consider argument as a parameter.

Mehadi Hassan
  • 1,160
  • 1
  • 13
  • 33