Scoping
closed

closed by
404 views
0 votes
0 votes
int i ;
program main ()
{
    i = 10;
    call f();
}

procedure f()
{   
    i = 20;
    call g ();
}
procedure g ()
{   
    print i;
}

What will be the output using Static Scoping and Dynamic Scoping ? 

My ans : 

In Static Scoping  Global variable is set by main firstly,now global i=10

upon calling f , it sets the Global variable i to 20.

Calling g ---> output is 20.

Dynamic Scoping output is also 20 .

Can someone check this ?

closed by

Related questions

1 votes
1 votes
1 answer
3
admin asked Oct 5, 2015
733 views
Find the output of the below program in case of Dynamic Scoping with call by need evaluation methodint x=10,y=10;main(){int x=2;int y=3;fun1(x+y,5);printf("x");}fun1(int ...
1 votes
1 votes
2 answers
4