943 views
4 votes
4 votes

a) a = 169, b = 13  b) a = 144, b = 12  c) a = 169, b = 12  d) a = 144, b = 13

my doubt is that as the parameters are passed by reference b should be 169 also.

1 Answer

Best answer
1 votes
1 votes
At first b value=12. It makes global b value as 12 too. Now, N is called and b value increments by 1. As it is pass by reference it refers to same b as global variable pointing to. And b value becomes  13. Global variable b also 13. Now, b is passed to M and b is passed with different name(called aliases) as a , where value of a is also 13.Now, to a*a=169. So, final a value is 169. global variable b is also 169.

Now, control return back to main, which prints b value same as global variable i.e. b=169
selected by

Related questions

1 votes
1 votes
1 answer
1
sushmitha asked Sep 10, 2018
652 views
can anyone explain by using static and dynamic programing ? what will be output for static and dynamic? #include<stdio.h>int x=10;void part1(int *a){*a+=x++;printf("%d"...
0 votes
0 votes
0 answers
2
saumya mishra asked Dec 16, 2017
899 views
Can anyone please explain what is the answer to this question by static and dynamic scoping?
0 votes
0 votes
0 answers
3
KISHALAY DAS asked Jan 10, 2017
278 views
ANS GIVEN A=169 B=13 HOW??