Scope, Visibility and Lifetime of variables

  Рет қаралды 24,910

Shahid Nihal

Shahid Nihal

Күн бұрын

This video has a complete description of what scope, visibility and lifetime of a variable is. I have tried to explain all necessary things related to scope, visibility and lifetime of a variable.
*Scope - Area in the program where the variable is available.
*Visibility - Area in the program where the variable is accessible.
*Lifetime - Time period for which a variable is stored in some memory space(main memory or register).
Types of Scope:
1. Program Scope - Variable is available throughout the program.
2. File Scope - Variable is available throughout the file.
3. Block scope - Variable is available throughout the block in which it is declared.
4. Function Scope - Variable is available throughout the function in which it is declared.(usually for labels)
5. Prototype Scope - Variables passes as parameters to a function have this type of scope.
Visibility is a subset of Scope.
A variable may be available throughout the program, but it may not be accessible at some parts.
Types of lifetime:
1. Static lifetime - All static variables have static lifetime. They are stored in the memory till the program terminates.
2. Automatic Lifetime - All auto variables have automatic lifetime. They are stored in the memory till the block terminates.
3. Dynamic Lifetime - All variables which are created dynamically using malloc/new and deleted explicitly using free/delete have Dynamic Lifetime.
After having done with this video, I would recommend you all to watch my video on Storage Classes. Link to that video is given below.
• Storage Classes in C -...
Thanks.
Please visit my channel page if you liked this video and make sure you subscribe to get more videos on programming.
Link to my channel - / @shahidnihal

Пікірлер: 32
@sejalbabar3562
@sejalbabar3562 3 жыл бұрын
I was reading regarding static variables and didn't knew what was scope and visibility ur video helped a lot!!!
@ShahidNihal
@ShahidNihal 3 жыл бұрын
Glad it helped!
@abhijeetraj7952
@abhijeetraj7952 6 жыл бұрын
Crystal Clear 🔥 Thank You So much. Thumbs up👍 👏
@ShahidNihal
@ShahidNihal 6 жыл бұрын
Thanks for your positive response!
@smit_XD
@smit_XD Жыл бұрын
Crystal Clear 🔥
@viragjain720
@viragjain720 3 жыл бұрын
Beautifully taught!
@מיכל-ס1ר
@מיכל-ס1ר Жыл бұрын
Thank you! Very clearly explained!
@ShahidNihal
@ShahidNihal Жыл бұрын
You are welcome!
@hudaadibahuda475
@hudaadibahuda475 4 жыл бұрын
Thank you sir..... valuable information 😊👍
@ShahidNihal
@ShahidNihal 3 жыл бұрын
Welcome 👍
@harshjoshi6257
@harshjoshi6257 5 жыл бұрын
Well done 👏👍 Invest a little more ,you will definitely get subscribers
@ShahidNihal
@ShahidNihal 5 жыл бұрын
Thanks a lot! I guess I'll start shooting videos again. You actually gave me hope. I lost hope thinking that I wouldn't get any subscribers and hence stopped shooting videos. Now, I'll definitely find time for shooting videos. Ty
@dhiraj.govindvira
@dhiraj.govindvira 5 жыл бұрын
Ha harsh
@meetpatel3974
@meetpatel3974 5 жыл бұрын
Ekdam sachi harsh.....
@dcurre
@dcurre 5 жыл бұрын
What if i do: int x = 1; f (int x){ x = x+1; } f(x); print(x); What's the value of the x (dynamic & static)? Does it gets modified by x+1 or keeps his original value? Good video tho ^^
@ShahidNihal
@ShahidNihal 5 жыл бұрын
This would print x=1.
@vrajpatel1877
@vrajpatel1877 3 жыл бұрын
Thank you very very much😊🤩
@ShahidNihal
@ShahidNihal 3 жыл бұрын
Most welcome!
@OsoGP
@OsoGP 6 жыл бұрын
great explanation thank you
@ShahidNihal
@ShahidNihal 6 жыл бұрын
Thanks!
@praneethsaitunuguntla7751
@praneethsaitunuguntla7751 3 жыл бұрын
excellent sir! Thank you ...
@ShahidNihal
@ShahidNihal 3 жыл бұрын
Most welcome!
@tejashwinireddypadigela7496
@tejashwinireddypadigela7496 6 жыл бұрын
Excellent Sir
@ShahidNihal
@ShahidNihal 6 жыл бұрын
Thanks a lot!
@pankajjatav6448
@pankajjatav6448 5 жыл бұрын
Available but not accessible then what for it is available if it is not accessible?
@aleemullakhan8514
@aleemullakhan8514 6 жыл бұрын
Good explanation!
@ShahidNihal
@ShahidNihal 6 жыл бұрын
+Aleemulla Khan Thanks
@sejalbabar3562
@sejalbabar3562 3 жыл бұрын
Pls makes videos this topic video wasn't available anywhere
@ShahidNihal
@ShahidNihal 3 жыл бұрын
Will upload on weekly basis
@victortanpengshen6454
@victortanpengshen6454 4 жыл бұрын
Got anyone can tell me what is the lifetime of variable in R programming?
@Frishta-e-Flak
@Frishta-e-Flak 11 ай бұрын
What is R programing
@soumyas7472
@soumyas7472 Жыл бұрын
Hi..Is this common for java programming language also?
Scope of Variables - Local vs Global
11:12
Neso Academy
Рет қаралды 404 М.
Life hack 😂 Watermelon magic box! #shorts by Leisi Crazy
00:17
Leisi Crazy
Рет қаралды 79 МЛН
didn't manage to catch the ball #tiktok
00:19
Анастасия Тарасова
Рет қаралды 30 МЛН
Стойкость Фёдора поразила всех!
00:58
МИНУС БАЛЛ
Рет қаралды 7 МЛН
Static And Dynamic Scoping
5:53
The Coding Ladder
Рет қаралды 28 М.
What is Scope in Python??
10:25
b001
Рет қаралды 51 М.
Pointers and dynamic memory - stack vs heap
17:26
mycodeschool
Рет қаралды 1,4 МЛН
Scope and Lifetime of Variables (Java Tutorial)
5:21
Bill Barnum
Рет қаралды 11 М.
How different are C and C++? Can I still say C/C++?
10:25
Jacob Sorber
Рет қаралды 225 М.
My 2 Year Journey of Learning C, in 9 minutes
8:42
VoxelRifts (PixelRifts)
Рет қаралды 624 М.
Life hack 😂 Watermelon magic box! #shorts by Leisi Crazy
00:17
Leisi Crazy
Рет қаралды 79 МЛН