in Programming in C edited by
3,562 views
6 votes
6 votes

In the following procedure

Integer procedure P(X,Y);
Integer X,Y;
value x;
begin
      K=5;
      L=8;
      P=x+y;
end

$X$ is called by value and $Y$ is called by name. If the procedure were invoked by the following program fragment

K=0;
L=0;
Z=P(K,L);

then the value of $Z$ will be set equal to

  1. $5$
  2. $8$
  3. $13$
  4. $0$
in Programming in C edited by
by
3.6k views

4 Comments

I think Error will come.

Value x ;

what it means and y is not even declared here.
0
0
I think answer will be 8
0
0
variable is not declared here, Did anyone get the value for this ??
0
0

@kpc this is pseudo-code so, do not consider any typing error... 

0
0

1 Answer

4 votes
4 votes

X=call by value  hence we pass 0 ,

Y=call by name hence we pass expression or variable and evaluate every time

After passing the value as ‘0’ and name as ‘L’

P=0+L   // here L=8 ;

P=8; / return

Z=8

Answer  B

2 Comments

But how to decide which value to be taken? Why L=8 and not 0?
0
0
X is called by value simply means actual value will be used irrespective of whatever value inside the function that is 0

Y is called by name means address of var will be used so value will be changed after calling the function Y=8
0
0
Answer:

Related questions