Category:C: Difference between revisions

Content added Content deleted
Line 69:
//procedure whose outcome does not need to be measured or remembered later.</lang>
 
Note that the variable names listed as arguments when declaring a function are justknown foras convenience<i>formal parameters</i> and only are there to define the function. TheyVariables with those names need not be declared noror defined in your actual function, nor do they refer to any variables in your program that happen to have the same name. It'sEssentially, onlyformal whenparameters aact functionas isplaceholders actuallyfor <i>used</i>the areactual thefunction argumentparameters variablesthat requiredyou'll tobe existusing.
<lang C>int foo(int x){
return x;
} // "x" doesn't need to be a variable in your real program. If it is, that's not related in any way to the "x" here.
} // the "x" here is just a placeholder for whatever actually goes in when you invoke foo.
 
int main()
Line 80:
int z = 2;
 
y = foo(z); //note that x was never involved. That's because the "x" earlier was justthe aformal placeholder nameparameter.
 
}</lang>