Concept:
Parameter passing is the mechanism used to pass data between a calling function and a called function.
• Pass by Value: A copy of the actual parameter's value is made in memory. Changes made to the parameter inside the function do not affect the original variable.
• Pass by Reference: The memory address (reference) of the actual parameter is passed. The function operates directly on the original variable.
Step 1: Analyzing Pass by Value.
In this mode, the formal parameter is a local variable initialized with the value of the argument. Because the function is working on a "clone," the original data in the caller remains untouched.
Step 2: Analyzing Pass by Reference.
In this mode, the formal parameter acts as an alias for the actual argument. Any operation performed on the parameter is actually performed on the original variable at its specific memory location. This allows the function to "reach back" into the caller's scope and modify data.
Step 3: Evaluating other options.
"Pass by constant" explicitly prevents modification. "Pass by result" is a mechanism where the value is copied back only when the function terminates, which is different from direct modification during execution.