1,262 views

1 Answer

0 0 votes
answer is c

first time when the plus(25) is called then,in plus function x=25, but a is not defined .if this was static scoping then it would have taken value 10 of global variable,but since it is dynamic scoping so it will find a in the function which is stacked below this function which is main function so ,here a is 1 hence 26 will be printed.

then a =3 then again plus(a) is called here x=3 a=3 hence 6 will be printed

inc() will do nothing to a as a is not static it is local variable so a will be 3 and will print 3 .last plus(a) will print 6 similarly
Position:
Show:

Related questions

1 1 vote
2 2 answers
5.2k
5.2k views
Ayush Upadhyaya asked Jan 3, 2019
5,205 views
#include<stdio.h int x=10; int main() { static int x=10; x+=f1()+f2()+f3()+f1(); printf("%d",x); return 0; } int f1(){static int x=25;x++;return x;} int f2(){int x=50;x++...
3 3 votes
2 2 answers
837
837 views
set2018 asked Oct 10, 2017
837 views
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();...
15 15 votes
1 answers 1 answer
6.4k
6.4k views
firki lama asked Jan 9, 2017
6,436 views
int a=0,b=0; int main(void) { int a=3; printf("%d%d",a,b); c(); printf("%d%d",a,b); return 0; } void c() { printf("%d%d",a,b); a=4,b=5; printf("%d%d",a,b); d(); printf("%...
1 1 vote
1 1 answer
986
986 views
srestha asked Mar 23, 2019
986 views
int x = 5, y = 10 ; void main ( ) { int i = 2, j = 3 A (i, j); } void A (int i, int j) { int x = 10, y = 5 ; i = i + x : j = i + y : printf ("%d %d", i, j); B (i, j); } v...