Aptitude | GATE CS 1998 | Question 48

What is the result of the following program?

program side-effect (input, output);
    var x, result: integer;
    function f (var x:integer):integer;
    begin
        x:x+1;f:=x;
    end;
begin
    x:=5;
    result:=f(x)*f(x);
    writeln(result);
end;

(A) 5
(B) 25
(C) 36
(D) 42


Answer: (C)

Explanation:

Quiz of this Question



My Personal Notes arrow_drop_up