440 views
1 votes
1 votes

My Query is as it is passing by reference so a in M actually refer to location b.So a=a*a=169 will be updated as b.Then how can b be 13?

Please anyone rectify me.

2 Answers

3 votes
3 votes
There is no variable declaration in main. So, b in main refers to global b and is initialized to 12.

In N also no declaration of b. So, it updates the global b to 13.

The reference of the global b is passed to M and M updates it to 169.

So, output a = 169, b = 169.
1 votes
1 votes

Answer is : a] 

Static scopinghttps://courses.cs.washington.edu/courses/cse341/03wi/imperative/scoping.html

Now,

if parameters are passed by values,

    a= 169 and b =13

and if parameters are passed by reference,

   a = 169 and b = 169

Big bros' advice : "Move forward.."

edited by

Related questions

0 votes
0 votes
0 answers
1
SAUMYA2019 asked Jan 24, 2019
237 views
in the soln how they are taking i?
1 votes
1 votes
0 answers
3
srestha asked Mar 6, 2019
779 views
void find(int x){ static int i=10,y=0; y=y+i; for(i;i>0;i=i-10){ if(x!=0) find(x-1); else{ printf("%d",y); } } }What will be output printed for find(4)?
2 votes
2 votes
1 answer
4