+ 5
Can someone define what the argument is in a function?? I understand what the parameters are...
3 Respuestas
+ 5
someFunction(a, b)
a and b are the parameters, when u call the function like someFunction(4, 20), 4 and 20 are the arguments
+ 4
Thanks!
+ 1
An argument of a function is a variable used as input for the function. When you define your function you should indicate what is the data type of the arguments.
For example:
int sum(int a, int b)
the arguments of this function are two integer numbers, a and b. (the output is also an integer) You can call this function in your main program by inserting numbers straight as arguments or you can add other variables (which correspond to appropriate type) as arguments.
For example, the lines of code below do the same thing:
int var1= 1;
int var2= 3;
cout << sum(var1,var2);
OR
cout << sum(1,3);