Call by Value and Call by Reference in C


Audience
Tags

I'm trying to understand the conceptual difference between call by reference, value, and name.

So I have the following pseudocode:
<code>foo(a, b, c)
{
b =b++;
a = a++;
c = a + b*10
}

X=1;
Y=2;
Z=3;
foo(X, Y+2, Z);</code>
What's X, Y, and Z after the foo call if a, b, and c are all call by reference? if a, b, and c are call-by-value/result? if a, b, and c are call-by-name?

Another scenario:
<code>X=1;
Y=2;
Z=3;
foo(X, Y+2, X);</code>
I'm trying to get a head start on studying for an upcoming final and this seemed like a good review problem to go over. Pass-by-name is definitely the most foreign to me.

Reference - https://www.scaler.com/topics/c/call-by-value-and-call-by-reference-in-…