454 views
3 votes
3 votes

int i=10;
main()
{
int i =5,k,i=6;
printf("enter value");
scanf("%d",&k);
if(k>0)
{
fun1();
}
else
{
fun2();
}
}

void fun1();
{
printf("%d",i);
}


void fun2();
{

int i=5;
printf("%d",i);
fun1();

}


what will the output using dynamic scoping?

2 Answers

0 votes
0 votes
by taking any value of k   (k>0 )

OUTPUT will be 6

 and if we take k=0

then , OUTPUT will be 5 5
0 votes
0 votes
Case 1:Suppose K is 10 then f1 calls

It will print 10 because value is not passed

Case 2:suppose K is -2

Then f2 calls in this case

5 10 prints as output

Related questions

1 votes
1 votes
2 answers
1
3 votes
3 votes
1 answer
3
dragonball asked Jan 14, 2018
899 views
How to solve any dynamic scoping question . Plz describe in detail.