Parameter Passing

Parameter passing is the process of passing arguments to a function.

Actual Arguments

  • Actual arguments are the values passed to a function’s formal parameters to be operated on.
  • Here, the values of birthYr (the user’s year of birth) and HSGradYr (the user’s year of high school graduation) are passed as the actual arguments to formal parameters n1 and n2.
  • Each call is part of the same Boolean expression ordered(birthYr, HSGradYr) and ordered(HSGradYr, colGradYr).
  • In the second function call of the expression, a different set of values HSGradYr and colGradYr are passed.
  • Formal parameter names n1 and n2, however, remain the same.
  • The correspondence between actual arguments and formal parameters depends on the order of the arguments, not their names.
  • Example: It's valid to pass num2 to n1 and num1 to n2.
  • The ordered function is invoked twice: once with arguments num1, num2, and another time with arguments num2, num1.
  • Each call is appropriate and consistent within the given context.