Call-by-value should just copy the values of the parameters and store them essentially as local variables, which will be thrown away after the execution of R. So, I'm almost certain the answer would be x=10, y=15 => ©. Now, if x and y were called explicitly inside of R, then the values would be updated (this only makes sense if x and y are global wrt procedure Q, but in this case they are).
Ex:
Procedure Q
begin
var x,y
Procedure R(a,b,c)
begin //a=15, b=10, c=15
b:=b+10; //b=20
a:=b+c; //a=35
end //no modification to original parameters, x and y
y=15;
x=10;
R(y,x,y) //Passing by value, no changes made
write(y,x)
end
On the other hand, call-by-reference will pass the address of the parameters to the procedure. So, any modification to a variable within the procedure will actually be changing the value at the given address in memory. Once the procedures ends, then the passed parameters will reflect any updates that have occurred.
Ex:
Procedure Q
begin
var x,y
Procedure R(a,b,c)
begin //a=15, b=10, c=15
b:=b+10; //b=20 (and x=b=20)
a:=b+c; //a=20+15=35 (and y=a=35)
end //x=b=20, y=a=c=35
y=15;
x=10;
R(y,x,y) //Passing by reference, update parameters
write(y,x) //write 35 20
end
Since the call was R(y,x,y), then a=c=y and x=b throughout the procedure since these are all just addresses that point to a value.