views:

48

answers:

2

How can i simulate calling by value-result in this example. Without adding variables and without change a variable name.?

Program one;
    var
      x:integer;
    Function two():integer;
        begin
           x:=x+1;
           two:=x;
        end;
    Procedure three(x:integer);
       begin
          x:=x+5;
          x:=two();
       end;
begin
x:=8;
three(x);
write(x);
end.
A: 

If it's homework, I don't think you will have to try var y hard to find the answer.

EDIT: The comment below is correct - maybe I was leading you up the wrong path - it's probably best to return to where we were and start from there.

mdma
Well, var ParamName: ParamType will pass ParamName *by reference*, and not *by value*, as normal, if ParamType is a simple type. But I really do not understand what the OP wants to achieve...
Andreas Rejbrand
A: 

Do to two() what three() already does.

Marco van de Voort