...
Logical-Reasoning
November 14, 2023
Question 10010 – Algorithms
November 14, 2023
Logical-Reasoning
November 14, 2023
Question 10010 – Algorithms
November 14, 2023

Programming

Question 16

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
Question 16 Explanation: 
If it is call by reference then answer is 42.
If it is call by value then answer is 36.
Correct Answer: D
Question 16 Explanation: 
If it is call by reference then answer is 42.
If it is call by value then answer is 36.

Leave a Reply

Your email address will not be published. Required fields are marked *