Academic Program

Function Parameters

Function Parameters

Parameters passed to a function are passed by value. Values passed to a function are copied into the local parameter variables. The original variable that is passed to a function cannot be modified by the function since only a copy of its value was passed.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
int a, b, c;
int foo(int x, int y);
 
int main(void)
{
  a = 5;
  b = 10;
  c = foo(a, b);
}
 int foo(int x, int y)
{
  x = x + (++y);
  return x;
}

The value of a is copied into x.
The value of b is copied into y.
The function does not change the value of a or b.