0
0
Compiler Designknowledge~20 mins

Parameter passing mechanisms in Compiler Design - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Parameter Passing Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Call-by-Value

Which statement best describes the call-by-value parameter passing mechanism?

AThe function receives a copy of the argument's value; changes inside the function do not affect the original variable.
BThe function receives the memory address of the argument; changes inside the function affect the original variable.
CThe function receives a reference to the argument; changes inside the function affect the original variable only if explicitly returned.
DThe function receives a copy of the argument's value and a reference to the original variable simultaneously.
Attempts:
2 left
💡 Hint

Think about whether changes inside the function affect the original variable.

📋 Factual
intermediate
2:00remaining
Identifying Call-by-Reference Behavior

In which parameter passing mechanism does the called function directly modify the caller's variable?

ACall-by-reference
BCall-by-name
CCall-by-constant
DCall-by-value
Attempts:
2 left
💡 Hint

Consider which method allows the function to change the original variable.

🔍 Analysis
advanced
2:00remaining
Comparing Call-by-Name and Call-by-Value

Consider the following code snippet in a language supporting call-by-name:

function f(x) { return x + x; }
f(3 + 4)

What is the difference in evaluation between call-by-name and call-by-value for the argument 3 + 4?

ABoth evaluate <code>3 + 4</code> once before the call.
BCall-by-value evaluates <code>3 + 4</code> twice; call-by-name evaluates it once before the call.
CCall-by-value evaluates <code>3 + 4</code> once before the call; call-by-name evaluates <code>3 + 4</code> twice inside the function.
DBoth evaluate <code>3 + 4</code> twice inside the function.
Attempts:
2 left
💡 Hint

Think about when the argument expression is evaluated in each mechanism.

Reasoning
advanced
2:00remaining
Effect of Call-by-Result on Variable Values

In the call-by-result parameter passing mechanism, what happens to the variable passed as an argument after the function finishes execution?

AThe variable remains unchanged regardless of the function's operations.
BThe variable is updated with the final value computed inside the function.
CThe variable is updated before the function starts execution and remains fixed during the function.
DThe variable is updated only if the function explicitly returns it.
Attempts:
2 left
💡 Hint

Consider when the variable's value is copied back to the caller.

Comparison
expert
2:00remaining
Distinguishing Call-by-Value-Result from Call-by-Reference

Which of the following statements correctly distinguishes call-by-value-result (copy-in copy-out) from call-by-reference?

ACall-by-value-result and call-by-reference are identical in behavior and timing of updates.
BCall-by-value-result passes the address of the variable; call-by-reference passes a copy of the value.
CCall-by-value-result evaluates the argument expression multiple times; call-by-reference evaluates it once.
DCall-by-value-result copies the argument value in and out, so changes inside the function do not affect the caller until the function ends; call-by-reference allows immediate changes to the caller's variable.
Attempts:
2 left
💡 Hint

Think about when the caller's variable is updated in each mechanism.