+ 2
I don't understand the difference between parameters and arguments, if they're both being sent to a function to be processed, and they're both variables, what's the difference?
4 ответов
+ 7
when you are defining a function, you say what parameters it would work with.
example: density(mass, volume).
when you call that function, you replace each parameter with an actual value. these actual values are the arguments.
say you want to calculate the density of a ball of mass 12kg and volume 4m³, you call the function 'density' with the arguments 12 and 4, like so:
density(12, 4);
+ 4
no parameter is called when we are declaring function writing its prototype whereas arguments word is used while calling out that function
+ 3
Argument is used to specify the value passed.
Parameter is used to specify the type and the variable which will hold the value
0
oh wait, the argument is a value and the parameter is a variable. Is that it?