Static and Dynamic Scoping (Solved Question 2)

preview_player
Показать описание
C Programming & Data Structures: Static and Dynamic Scoping (Solved Question 2)
Topics discussed:
1) The solution of GATE 2016 problem on Call by Reference and Dynamic Scoping.

Music:
Axol x Alex Skrindo - You [NCS Release]

#CProgrammingByNeso #CProgramming #StaticScoping #DynamicScoping
Рекомендации по теме
Комментарии
Автор

First of all the question is demanding to assume pass by value as pass by reference which is somewhat thats fine, somehow the assumptions is in the control....over this there is this statement a=1 in the function m(y) which is confusing many viewers since it is not mentioned weather that 'a' is accessing the global variable or creating a local variable....I am sure most of the viewers would have considered that variable 'a' is accessing the global variable.

suchetamberker
Автор

2:08 sir how we know that the variable a is local to that function
It might be possible that, that function is trying to modify the value of the global variable a

ritikshrivastava
Автор

This is something that made me crazy 😂

nihalpandey
Автор

3:27
I think for many people it was confusing.
From where 'a' in n(x) function is needed to be found? Should you take the global variable a or take the local a mentioned in m(y)?
Right? Which one to take?

So, here's the place where you think things dynamically. As we are assuming dynamic scoping, so we will find the a in the function itself and, then the caller of the function and so on.
So, considering dynamic function the 'a' in n(x) will access the 'a' in m(y) function and not from the global variable.

maharun
Автор

sir how come we will know that a=1 is local to the fun or it is changing the value of the global variable a=3 declared earlier.

nikhilanand
Автор

That a is local for m is an assumption but the question only does assumptions of dynamic scoping and by reference addressing... So in my opinion is impossible to give the right answer, unless you also assume a as global and find that result is not listed in the options..

maurizioalfieri
Автор

I have one question to ask.If the parameters are passed by value, then will the answer be 4, 2?

shibayanmondal
Автор

Nice explanation.if every student find the right time of studying in this channel his knowledge is 100/100.i am so late too seen this video....❤️❤️❤️❤️❤️❤️❤️

soumyamondal
Автор

"In void m(y) a in not declared so any changes made to a will reflect in global "a" so global a value will change to 2 " this is all over my head please correct me if am wrong plus its call by reference so any change made to formal parameters will reflect in actual so either way global "a" will change to 2 i guess

poppychan
Автор

I got it right in 1st attempt... Thanks to your great teaching😍💝🙌

AyushKumar_-jdkd
Автор

i have not understood in function m(y), a = 1; is initialization of global variable or declaration of new one.

AkshayKumar-byfd
Автор

the confusing thing is when a=1 is encountered, is it a declaration with initialization or just an assignment to the variable a?

deberjeetusham
Автор

sorry sir but in function m(y) we are manuplating the a which is a global variable because a is not declered in m(y)

mohitkumarbansal
Автор

There is a small mistake here in function m
Local variable a should be defined as int a, but here we r updating global variable a =1
So op will be 00

prateekdubey
Автор

how did the a changed to 4 in n(x) as it was 2 in m(y) ?

mohammedisarezwani
Автор

in m() function how a is local it simply change the global value of a to 1 . It's confusing any one ??

mastermind
Автор

How can a be local to the m( ) function when it was not declared within it?

smrititilak
Автор

dynamic scoping doesn't make any sense when it comes to call by

kausachan
Автор

Answer wil be 0 0 .Since in m( ) function it is "a=1" and not "int will change the value of global variable a to 1 from 0

dikshawadankar
Автор

Everyone who's confused...
First of all, it's not C language in the question so don't misunderstand it with C, it is an hypothetical language in which dynamic scoping is used !! So int a or int *y, *x are not necessary in it !!

IronMan_.