Local, Global , Static Variables (in C) - Types of variables

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

Logic First

Logic First

4 жыл бұрын

Scope and memory management for local, global and static variables is discussed in detail with examples.
- What are local variables? What is the scope of local variables?
How local variables are allocated in memory? How local variables occupy the stack frames within the stack segment of RAM? Can you have two local variables with same name in two different functions?
- What are global variables? How they are managed in memory? Storing of global variables in data segment of RAM. Global and static variables initialized to zero.
- What are static variables? How are they stored in memory?
Program links,
Mastering loops playlist,
• Mastering loops
Learn C programming playlist,
• Learn C programming
Website link,
logicfirstcoding.com/

Пікірлер: 44
@narasimhapalla3529
@narasimhapalla3529 2 жыл бұрын
Thank u mam
@raghav5074
@raghav5074 3 жыл бұрын
Dear Ma'am, thanks a lot for such a concise and neat explanation. Believe me, your tutorials are just 24 karat gold.
@akhil2721
@akhil2721 Жыл бұрын
Mam you are life saver , I am learning c from past 4 months but was not aware with such basic concepts ,thanks for such a wonderful explanation you are truly a gem of teaching.
@paulg.3067
@paulg.3067 3 жыл бұрын
Thanks a lot, best explanation so far for me personally!
@ishaankulkarni49
@ishaankulkarni49 3 жыл бұрын
helped in preparing for my end sem tomm. thanks!
@rajkumarmaity1243
@rajkumarmaity1243 3 жыл бұрын
My doubts on type of a variable are cleared.Thanks a lot ma'am
@anushaanusha426
@anushaanusha426 3 жыл бұрын
My all doubts about variables got clarified . Thanks a lot mam
@jvrs9070
@jvrs9070 2 жыл бұрын
Thank you for making my life so much easier!!
@rushikeshpanchal1349
@rushikeshpanchal1349 2 жыл бұрын
Thanks Ma'am for such great explanation 👍
@codewithme2746
@codewithme2746 3 жыл бұрын
Thank you...very clear explanation 👍🏻👍🏻
@takeshiiixD
@takeshiiixD 3 жыл бұрын
Very well explained. Thanks a lot!!! =D
@reneezmp
@reneezmp 2 жыл бұрын
Thank you so much, that was a very precise explanation =)
@udhayaprakash7833
@udhayaprakash7833 3 жыл бұрын
wow !!!!!!!!!!!! I love your explanation keep doing it more.
@Vibrant_Gna
@Vibrant_Gna 3 жыл бұрын
Really well explained Thanks a lot
@mangolureddemma3301
@mangolureddemma3301 3 жыл бұрын
A clean and wonderful explanation mam..
@tayyabjatoi8644
@tayyabjatoi8644 4 жыл бұрын
Awesome explanation.
@vikramreddy5631
@vikramreddy5631 Жыл бұрын
Thanks 🙏🏻
@romanking8017
@romanking8017 2 жыл бұрын
Thanx mam from tamil channel ❤️
@ShreyaSingh-vr9qi
@ShreyaSingh-vr9qi 4 жыл бұрын
Nice explaination !!
@fardilviews
@fardilviews 4 жыл бұрын
thanks a lot......
@chamangupta4624
@chamangupta4624 3 жыл бұрын
thanks , ur voice seems like the railway station announcement !!
@hfe1833
@hfe1833 3 жыл бұрын
I like this tutorial for C Topic closer than the machine
@cr7johnChan
@cr7johnChan 3 жыл бұрын
Best !
@venkateshgaikwad6164
@venkateshgaikwad6164 4 жыл бұрын
Very helpful
@omarkhaled-vy8tq
@omarkhaled-vy8tq 4 жыл бұрын
good explaination
@user-hw1gf6mr7b
@user-hw1gf6mr7b 2 ай бұрын
Bestt
@rushitambe6874
@rushitambe6874 2 жыл бұрын
Super
@ruchisingh3363
@ruchisingh3363 4 жыл бұрын
Nice mam
@meenarsrk6450
@meenarsrk6450 2 жыл бұрын
Nicely explained....Thank you!!!Can you also factor in extern KEYWORD to this. Thanks again!!!
@prity2673
@prity2673 4 жыл бұрын
NYC mam😊
@priyaj9908
@priyaj9908 4 жыл бұрын
Mam when the memory will allocate for static variables which is declared inside some function.and when memory allocates for local variable? Is it compile time or runtime?
@logicfirst31
@logicfirst31 4 жыл бұрын
memory allocation is a little complicated. compiler allocates virtual memory in both cases but the real allocation takes place only run time for everything. you can chk accepted answer here to know what compile time allocation really means stackoverflow.com/questions/21350478/what-does-memory-allocated-at-compile-time-really-mean#21350570
@priyaj9908
@priyaj9908 4 жыл бұрын
@@logicfirst31 thank u ma'am 🤩
@chandureddim4327
@chandureddim4327 3 жыл бұрын
mam, i have another doubt mam that. if we create a another scope within a scope does another stack is created as it is not accessible to outer scope #include int main( ) { int a=10; { int b=190; //here we can access variable a mam. } printf("%d",b); //error //but why cant we access variable b here ..does scope within a scope leads to creation of another stack mam ? } thanks in advance mam....
@logicfirst31
@logicfirst31 3 жыл бұрын
Great question chandu. I am honestly not sure about this as none of the materials or books i refer never talk about this. Memory management gets much complicated if you dig deeper. The video is just a bird's eye view.
@vikramreddy5631
@vikramreddy5631 Жыл бұрын
Yes when ever you create a {} a new stack is created and treats as new variable
@chandureddim4327
@chandureddim4327 3 жыл бұрын
mam, i have a doubt that do memory is allocated for local variables while writing code ? int main ( ) { int a; a=10; /* does while writing this line do memory is created for a mam ? thanks in advance waiting for ur reply mam.
@logicfirst31
@logicfirst31 3 жыл бұрын
no no. it only happens when you compile.
@chandureddim4327
@chandureddim4327 3 жыл бұрын
@@logicfirst31 if u dont mind , i want to mention one point mam that please take a complex problem and do memory representation to it mam from compilation to running it what happens to it make a clear explanation to it mam.thank you mam.
@logicfirst31
@logicfirst31 3 жыл бұрын
It sounds interesting but I am not qualified enough for that. Because as i programmer I think this level of understanding is sufficient. what you are saying is the job the person who is coding the programming language itself.
@chandureddim4327
@chandureddim4327 3 жыл бұрын
@@logicfirst31 i just asked u because i thought that u r the one stackoverflow (id -manu ) answered the question in the given below link mam. (i got to this assumption because u posted this link on priya j 's reply in this video mam) stackoverflow.com/questions/21350478/what-does-memory-allocated-at-compile-time-really-mean#21350570 when i gone through those answers i got to know that address will be there in stack but u said in video as values will be there ,so bit very confused and asked u to do a video on it mam.please make video on it mam. i believe u can please make a try mam. please! it would be very useful mam.
@logicfirst31
@logicfirst31 3 жыл бұрын
ok chandu i will give a try
@prince10oct
@prince10oct 4 жыл бұрын
its too complecated.
Global Variables in C++... not as easy as it seems
18:25
The Cherno
Рет қаралды 61 М.
Understanding Static, Stack, and Heap Memory Regions (Examples in C)
33:29
Inside Out 2: Who is the strongest? Joy vs Envy vs Anger #shorts #animation
00:22
No empty
00:35
Mamasoboliha
Рет қаралды 9 МЛН
Scope of Variables - Local vs Global
11:12
Neso Academy
Рет қаралды 394 М.
A const int is not a constant.
9:16
Jacob Sorber
Рет қаралды 66 М.
Stack vs Heap Memory - Simple Explanation
5:28
Alex Hyett
Рет қаралды 211 М.
you will never ask about pointers again after watching this video
8:03
Low Level Learning
Рет қаралды 2,1 МЛН
TIA Portal: Static vs Temp Variables
14:26
Hegamurl
Рет қаралды 40 М.
Memory leak in C/C++
17:55
mycodeschool
Рет қаралды 243 М.
0x13 - Const and Static Variables | C/C++ Beginners Tutorial
37:02
Header Issues: Guards, Name Mangling, and extern "C"
8:32
Jacob Sorber
Рет қаралды 76 М.
Local vs global variables in C
8:32
CodeVault
Рет қаралды 17 М.