###### Programming

October 10, 2023###### Database-Management-System

October 10, 2023# Programming

Question 19 |

What is printed by the print statements in the program P1 assuming call by reference parameter passing?

Program P1() { x = 10; y = 3; func1(y,x,x); print x; print y; } func1(x,y,z) { y = y+4; z = x+y+z; }

10, 3 | |

31, 3 | |

27, 7 | |

None of the above |

Question 19 Explanation:

Here, variable x of func1 points to address of variable y.

And variable y and z of func1 points to address of variable x.

Therefore, y = y+4 ⇒ y = 10+4 = 14

and z = x+y+z ⇒ z = 14+14+3 = 31

z will be stored back in k.

Hence, x=31 and y will remain as it is (y=3).

Hence, answer is (B).

And variable y and z of func1 points to address of variable x.

Therefore, y = y+4 ⇒ y = 10+4 = 14

and z = x+y+z ⇒ z = 14+14+3 = 31

z will be stored back in k.

Hence, x=31 and y will remain as it is (y=3).

Hence, answer is (B).

Correct Answer: B

Question 19 Explanation:

Here, variable x of func1 points to address of variable y.

And variable y and z of func1 points to address of variable x.

Therefore, y = y+4 ⇒ y = 10+4 = 14

and z = x+y+z ⇒ z = 14+14+3 = 31

z will be stored back in k.

Hence, x=31 and y will remain as it is (y=3).

Hence, answer is (B).

And variable y and z of func1 points to address of variable x.

Therefore, y = y+4 ⇒ y = 10+4 = 14

and z = x+y+z ⇒ z = 14+14+3 = 31

z will be stored back in k.

Hence, x=31 and y will remain as it is (y=3).

Hence, answer is (B).

Subscribe

Login

0 Comments