[cs13001] Arguments / Parameters

Mikhail Nesterenko mikhail at cs.kent.edu
Sun Sep 23 19:19:04 EDT 2012


> 
> While reading this obscenely large book (Problem solving with C++),
> I read this; "The value the function starts out with is called it's
> argument.", I know that, but can I also say "The value the function
> starts out with is called it's parameter." ? Because from my
> understanding, they are both the exact same thing.

Understanding the difference between an argument and a parameter is
very important. A parameter is a placeholder that the function
definition operates on. An argument is the value that will be assigned
to the parameter once the function is invoked. The relationship
between an argument and a parameter is similar to that between a cup
and milk that goes into this cup.

Moreover, arguments and parameters appear in different places in the
code: parameters are used in a function definition, while arguments
appear in a function invocation. In the below example, "a" is a
parameter while "22" is an argument to function add1()

Thanks,
-- 
Mikhail

--------------------
// here "a" is a parameter
int add1(int a){
    a++;
    return (a);
}

// somewhere inside main()
...
int b;
b = add1 (22); // here 22 is an argument
...
-------------------



More information about the cs13001 mailing list