What is the result of the following program?
program side-effect (input, output);
var x, result: integer;
function f (var x:integer:integer;
I tried to run this program in pascal but it is showing fatal error.
how will call by reference work here?
Rupendra Choudhary srestha ,how it get 49??? ,1st f(x) will give 6 and second will give 7, so does it be 42?
Answer is (d) :
Why? Since in question syntax is like pascal we will assume that this segment follows rules of Pascal programming language. Then , there is rule in pascal that if in declaration of formal parameters keyword 'var' is prefixed , then the procedure follows call by reference and modifies the actual values of actual params. So the answer is 42.