Mathematics I / Functions and Modularity
Practice question · Put in order

Order what happens when the call f(3, 4) is evaluated.

Hints
  1. Nothing can enter the function before the caller has values to pass.
  2. The locals outlive the body but not the return.
Show the answer
  1. The caller evaluates the arguments 3 and 4
  2. The arguments are bound to the function's parameters
  3. The body runs, creating local variables as it goes
  4. The function returns its result to the caller
  5. The function's local variables cease to exist
Why

Arguments are evaluated, bound to parameters, the body runs, a value comes back, and the locals vanish. That last step is encapsulation in action: the internals are gone, so only the returned value can influence the caller.

Read the lesson: Functions and Modularity →

Practise Functions and Modularity

The app has 6 more questions on this lesson, and keeps your place in the course. Mathematics I is free to start.

More questions on Functions and Modularity