Please tell me the difference between an argument and parameter...i was really confused in understanding the difference between these two.
6 6256
A parameter is a named value whereas an argument is just a value. For example: - 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: - 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.
donbock 2,426
Recognized Expert Top Contributor
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.
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 - #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 - #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;
-
}
-
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.
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/
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Frans Englich |
last post by:
Hello,
In my use of getopt.getopt, I would like to make a certain parameter
mandatory. I know how to specify such that a parameter must have a value if
it's specified, but I also want to make...
|
by: Dave |
last post by:
Hello all,
I hope the context to my problem shown below is adequate but not
overwhelming. I tried to keep it minimal.
At the line indicated (in comment form) in the source below, the...
|
by: Dan |
last post by:
Is it just me, or is the removal of support for the word "void" in a
parameter list extremely annoying? Some of us have been programming for
years putting "void function_name (void)" - and it...
|
by: VMI |
last post by:
Can I call a stored proc from .net with a parm that changes during the SP?
For example, I call the SP with parameter sMyVariable (which changes in the
SP), and when I access it after the SP is...
|
by: Autofreak |
last post by:
Hello,
I am trying to create a public void delegate GenericEventHandler in the event publishing class with a generic parameter. The parameter is of a variable type. The parameter/argument will be...
| |
by: puzzlecracker |
last post by:
C++ standard says the following:
I am reading through c++ standard and have a difficulty understanding
the difference between these two terms.
Thanks,
puzzlecracker
|
by: Mike Copeland |
last post by:
How do I distinguish a pointer to a character variable versus a
pointer to a C-type character string? For example,
void Funct1(char *str) // "str" is a character string variable
void...
|
by: cooolsson |
last post by:
what's the difference between an argument and a parameter. My friend and i are going nuts over this question.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |