Variable Modifiers − Static

  Рет қаралды 241,972

Neso Academy

Neso Academy

6 жыл бұрын

Programming & Data Structures: Static variable modifier in C programming.
Topics discussed:
1. Static modifier.
2. Use of static modifier.
3. Global variable vs static variable.
C Programming Lectures: goo.gl/7Eh2SS
Follow Neso Academy on Instagram: @nesoacademy(bit.ly/2XP63OE)
Follow me on Instagram: @jaspreetedu(bit.ly/2YX26E5)
Contribute: www.nesoacademy.org/donate
Memberships: bit.ly/2U7YSPI
Books: www.nesoacademy.org/recommende...
Website ► www.nesoacademy.org/
Forum ► forum.nesoacademy.org/
Facebook ► goo.gl/Nt0PmB
Twitter ► / nesoacademy
Music:
Axol x Alex Skrindo - You [NCS Release]
#CProgrammingByNeso #CProgramming #VariableModifier

Пікірлер: 144
@Hiyori___
@Hiyori___ 3 жыл бұрын
I think there's no other place on the internet where this concept is expressed as thoroughly as here
@mukulmalviya1605
@mukulmalviya1605 3 жыл бұрын
yes
@kunal-factz
@kunal-factz 5 ай бұрын
Yes ofc
@pulaksen4774
@pulaksen4774 3 жыл бұрын
this is a god gifted channel. LOVE YOU SIR G
@dipeshsamrawat7957
@dipeshsamrawat7957 3 жыл бұрын
Exactly, broh 💝.
@prakashchandra9353
@prakashchandra9353 2 жыл бұрын
He is teaching everything or not
@akshitarora470
@akshitarora470 6 жыл бұрын
These lectures are clearing all my little doubts like no other KZbin tutorial ever did! Thanks a lot for this series and please upload more stuff on C, C++ or maybe even Python! This channel is a blessing, thanks a lot
@gnesoni3349
@gnesoni3349 2 жыл бұрын
best way to explaining basics, such a type of simplicity
@castiel0504
@castiel0504 3 жыл бұрын
Since I see few comments out there that contain this error - " undefined reference to `increment' ". Maybe you are not using Code Block as me(Visual Studio Code here), or whatever IDE of your choice is, you just need to add #include "add.c" in the main.c . Hopefully this helps someone in the future.
@aniketkumre4231
@aniketkumre4231 2 жыл бұрын
plz explain it
@jonaxkariuki
@jonaxkariuki 2 жыл бұрын
just declare the increment () function in the main file
@sahraouibekkai423
@sahraouibekkai423 Жыл бұрын
thank uu broo
@iamarpit.sharma
@iamarpit.sharma Жыл бұрын
This is so helpful bro thank you
@awesomejaphet
@awesomejaphet Жыл бұрын
So helpful
@iamsunnymac
@iamsunnymac 3 жыл бұрын
Awesome Explanation.... I am also professor , Still watching the playlist! 👍
@omniaayman4323
@omniaayman4323 2 жыл бұрын
The way you explained this was just amazing. Can't thank you enough.
@erdhamo2791
@erdhamo2791 6 ай бұрын
Please make series on embedded software engineering, how we can leverage the power of C/C++ in embedded systems. Your courses are really helpful for students and developers ❤
@Surya045_
@Surya045_ 3 жыл бұрын
Congrats neso academy for 1.0M subscribers🥳🥳🥳🥳
@anfelsarabouachat8338
@anfelsarabouachat8338 4 жыл бұрын
explication extraordinaire franchement j'ai bien appris merci infiniment thanks alot from algeria i learned alot
@AhmeD-cp4qi
@AhmeD-cp4qi 3 жыл бұрын
thank you so much sir you really helped me a lot , much love from Egypt
@erahaez4266
@erahaez4266 2 жыл бұрын
your channel is a blessing for me......keep on making these kind of videos
@Jkt61205
@Jkt61205 3 жыл бұрын
Neso academy you are the best,Thank you so much.all i ask is please start classes on python also,because i can't even imagine to learn something in youtube channel other than Neso academy😂😂😁,so please start classes on it.again thanks a lot.
@avi130avi130
@avi130avi130 3 жыл бұрын
me too.. 👍🏻
@stevefox2318
@stevefox2318 3 жыл бұрын
this is a legendary video series each of my doubt is clear now HATSOFF NESO ACADEMY
@accessdenied9393
@accessdenied9393 3 жыл бұрын
Bro you actually explain, why the logic is logical!
@BrentArtuch
@BrentArtuch 4 ай бұрын
Best C tutorial out there rn. Thank you!
@UrKnownledgeBoard
@UrKnownledgeBoard 6 жыл бұрын
Awesome lecture....!!!!
@abdelrahmansayed4865
@abdelrahmansayed4865 4 жыл бұрын
I want to thank you very much your explanation is impressive, I have watched read a lot of videos explaining the static keyword and the other modifiers keywords but sir your the best, there is a little suggestion that is to draw Memory layout to make students imagine how the program flow, again thanks for your big effort
@vanditdubey
@vanditdubey 4 жыл бұрын
I seriously think these lectures are not for any noobie or a complete beginner. These are useful for the programmers who have a basic knowledge of C or any other programming language. They have explained all the concepts a little bit early so basically what will happen is everything will bounce of your head. So I recommend you to first learn the basics then come to this channel to furnish your Skill cause they have an amazing knowledge and they know what to teach. But first the basics !!!!!!!!! Go Learn them and then come back here......………….
@kalyan3285
@kalyan3285 3 жыл бұрын
Bro from where i have to start i don't have knowledge about programming pls answer bro if you see this
@KavisivaKumar-pb9pu
@KavisivaKumar-pb9pu 9 ай бұрын
check their full playlist if you are a newbie(this is for people who read this comment in future)
@vanditdubey
@vanditdubey 9 ай бұрын
@@kalyan3285 wohhhhh I’m coming back to this comment after 2 years 🤣 I hope you know programming now dude
@vanditdubey
@vanditdubey 9 ай бұрын
@@KavisivaKumar-pb9pu I still abide by my comment even now because it’s been 2+ years I’ve been coding
@KavisivaKumar-pb9pu
@KavisivaKumar-pb9pu 9 ай бұрын
@@vanditdubey yeah I understand your opinion but I have started coding just 2-3 weeks ago along with college studies ,but their videos are very helpful though sometimes it could be hard( I came back to revise static ),chatgpt or just googling or stackoverflow helps me understand those Also do u have any other resources that could help me pls do mention them
@josuegisber8150
@josuegisber8150 2 жыл бұрын
Great Job on explaining this lesson! But one question that came to my mind was if stactic is constant, how come you can update its value? is there an explanation for that? or did I missed something? Again, thank you so much for the hard work you had put on this series of lecture. I'm really enjoying it!
@VasaMusic438
@VasaMusic438 4 жыл бұрын
Great Lesson !!! Thank you !!!!!
@agamgill9563
@agamgill9563 6 жыл бұрын
as always great.....thank u sr
@asura-2467
@asura-2467 3 жыл бұрын
knew static but i was unable to unable understand it's usage or definition properly. I like ur way of teaching i.e first show the problem with a program demo then solving it as well as explain the topic. Thanks to u i was able to learn and understand many topics in c
@vishalkudva3420
@vishalkudva3420 4 жыл бұрын
Your are amazing teacher. 🙏
@Aabara_ka_dabara
@Aabara_ka_dabara Жыл бұрын
awesome explanation ... thankyou neso
@hammadmemon4739
@hammadmemon4739 2 жыл бұрын
how a person can teach like that 🔥🔥🔥🔥♥️♥️♥️
@Nitianboyz
@Nitianboyz 3 жыл бұрын
jaspreet sing sir...great
@NoName-vg8vf
@NoName-vg8vf 4 жыл бұрын
clear as crystal
@mrpositive6853
@mrpositive6853 Жыл бұрын
Very good lecture,understandable,thanks for videos.
@harshitchauhan2531
@harshitchauhan2531 2 жыл бұрын
bro love you finally i again start understanding c
@RishabhRawat_98
@RishabhRawat_98 5 жыл бұрын
Grt lesson👌.
@Dontever_throw_trash_out
@Dontever_throw_trash_out 5 жыл бұрын
explanation is damn good thanks neso academy for providing this please start machine learning series as it is boom tech in the coming years
@deboshreedey2333
@deboshreedey2333 6 жыл бұрын
Very nice video .....sir please complete the syllabus soon
@TheFactsThatShowYouWise
@TheFactsThatShowYouWise 2 жыл бұрын
your explanation is quite excellent
@preethichintam5239
@preethichintam5239 Жыл бұрын
Thank you I learnt a lot of basics
@naveenp8203
@naveenp8203 Жыл бұрын
Excellent explaination
@deepakbhardwaj3141
@deepakbhardwaj3141 6 жыл бұрын
You explained it in an very effective way and thank u for ur efforts u r awesome sir.....
@bhaskarraop3649
@bhaskarraop3649 3 жыл бұрын
Lots of love to neso
@yogendragangwar9795
@yogendragangwar9795 2 жыл бұрын
Nice explanation.
@dipeshsamrawat7957
@dipeshsamrawat7957 3 жыл бұрын
I love Neso Academy 💝.
@Jkt61205
@Jkt61205 3 жыл бұрын
sir i have a doubt how the compiler understands that the add.c file which is used for increment here is in another file without using a "EXTERN"modifier...
@andistheinforitbutso7513
@andistheinforitbutso7513 2 жыл бұрын
Linker
@true4189
@true4189 3 жыл бұрын
Thank u
@prajwaljarali
@prajwaljarali 2 жыл бұрын
Thanks
@lifeofajointlover
@lifeofajointlover 4 жыл бұрын
Seriously a bless
@mohamedouizar848
@mohamedouizar848 2 жыл бұрын
thanks
@SaiCreations-xq4nk
@SaiCreations-xq4nk Жыл бұрын
Super sir 🎉❤😊
@lifeofajointlover
@lifeofajointlover 4 жыл бұрын
U r great
@lifeofajointlover
@lifeofajointlover 4 жыл бұрын
Love u sir
@andistheinforitbutso7513
@andistheinforitbutso7513 2 жыл бұрын
Gud morning sir... 🌄 Thank you sir
@porankirajkumar4709
@porankirajkumar4709 4 жыл бұрын
When you declared the vairable globally without assigning the value should be 0 so the value is 1 and when we called the increment function again we go to the function and the variable is global is not changed then how the value becomes 2??
@hemangmitra7346
@hemangmitra7346 2 жыл бұрын
In add.c, I have not initialized the count variable like *int count;* after running I get the output 3 how ?
@petar7867
@petar7867 Жыл бұрын
note, while you cannot initialize a static variable with a variable, you can still assign to it a variable later on.
@ritamchatterjee3307
@ritamchatterjee3307 3 жыл бұрын
sir,what stdlib header file works for
@rachanajingade3925
@rachanajingade3925 5 жыл бұрын
Hello sir, How did you access count variable in main.c from add.c when it is declared as static int count? When you said that static variable can't be accessible outside the present file?!
@shubhamthakur3706
@shubhamthakur3706 4 жыл бұрын
hes not accessing the count variable in main.c but hes calling the function...so whatever the value is being returned by the function(return command is giving the number stored in variable) ...that value is being accessed cuz return function is doing that....variable count is never being accessed by the main.c
@intelchip_x86
@intelchip_x86 3 жыл бұрын
@@shubhamthakur3706 exactly
@josuegisber8150
@josuegisber8150 2 жыл бұрын
when I call the function increment in the main function file it gives me the error: "Implicit declaration of function 'increment' is invalid in C99". To fix it, I have to declare a prototype of the function in the top of the file... Any reason why your work and mine don't?
@venkatavinod2798
@venkatavinod2798 3 жыл бұрын
auto,static,extern,register are storage classes or modifiers??/
@dipesh1401
@dipesh1401 4 жыл бұрын
you are a genius😎😎😎😎
@roshankumarparihar6104
@roshankumarparihar6104 3 жыл бұрын
how i get to know that that is a automatic integer. i mean it is true always that every variable is auto please ans if u understand my que.
@aravindperiketi7540
@aravindperiketi7540 3 жыл бұрын
why we assign static constant value, why cant ?could you please tell what is reason behind hit
@baratammadhan1239
@baratammadhan1239 3 жыл бұрын
Sir, Please make the videos of Mechanical engineering subjects
@lohqingzhen
@lohqingzhen 6 жыл бұрын
Why we no need to include the add.c file in main.c in order to use the function? We need to include the file, doesn't it?
@paritagojariya5300
@paritagojariya5300 Жыл бұрын
Hello there, Thanks for your great work. I'm trying to do the same thing in visual studio code. It's given me an error undefined reference to 'increment'. Can you please tell me how to solve it? I've tried but couldn't solve it. Thanks in advance!
@sadafaafreenansari6099
@sadafaafreenansari6099 Жыл бұрын
Add #include "add.c" in main.c file
@compangit1524
@compangit1524 Жыл бұрын
Commen for myself: Review that global variables are automatically initialized to 0. Variables uninitialized and local to functions are assigned garbage value. Putting static keyword before a variable makes it visible only to its current scope. For example, a static global is only visible within its file, and a static inside a function is only visible within its function. The static keyword also assigns an uninitialized variable inside a function equal to 0 instead of garbage. Static variables also don't get destroyed after a function call. Static variables can ONLY be assigned constant values. Static means occupying fixed memory
@neerajr8182
@neerajr8182 3 жыл бұрын
Point 3 in the take away is inaccurate. While you can initialise a static variable only with a constant or a constant variable, you CAN assign static variables using function returns or other types of variables.
@harisrik2082
@harisrik2082 12 күн бұрын
Team, kindly upload ALP playlist fully
@Abi_Mehandi_Arts
@Abi_Mehandi_Arts 5 жыл бұрын
sir i have a doubt how the compiler understands that the add.c file which is used for increment here is in another file without using a "EXTERN"modifier... and also... is the function repeats three times i.e. whether it is performed three times... then output must be 1 1 1 please explain sir.....
@anweshamandal6058
@anweshamandal6058 5 жыл бұрын
only 1 printf statement is present
@rohinishah1294
@rohinishah1294 4 жыл бұрын
How can we reassign value to the "value" Variable...?!!!???
@liksondebnath4901
@liksondebnath4901 3 жыл бұрын
how can i link two files in vs code?/
@nikhilanand984
@nikhilanand984 4 жыл бұрын
sir so extern can access both global as well as local variable?
@sourabh8748
@sourabh8748 4 жыл бұрын
Yes
@friendsfandom
@friendsfandom 3 жыл бұрын
Well I had doubt in add.c you did not specify any header files y?
@meghnachowdary
@meghnachowdary 3 жыл бұрын
Sir, when we initialized static int count=3; How we still got output as 6? i. e. Even if we initialise it as 3, can static still retain the new value?
@lekshmipriyasb5055
@lekshmipriyasb5055 3 жыл бұрын
initialized as 3,and incremented 3,total is 6
@harshithagowda3707
@harshithagowda3707 4 жыл бұрын
When STATIC makes it private ( where other file can't retrieve the value) then by making a command how will we get the O/P as 3 ??
@lockdowntrendings1207
@lockdowntrendings1207 Жыл бұрын
Is it possible to create a c program without main function🤔
@aneeltripathy7420
@aneeltripathy7420 3 жыл бұрын
Isn't a word initialized to a constant value isn't itself a constant ?
@amruthaganjam4968
@amruthaganjam4968 2 жыл бұрын
cant we do soo...like this for incrementation i= 1 ; i < = 10 ; i ++....uhu..if we write this by using orintf and scanf the output will be 10 time like if i write my name in during run it will show my name 10 times.... i said it since code should be very very small soo
@Official-tk3nc
@Official-tk3nc 4 жыл бұрын
Guys they are providing everything for free and some idots dislikes these types of videos. I think they need mental treatment
@vinun2163
@vinun2163 4 жыл бұрын
Since v r uing two file... We have to use "Extern modifier" then only the linker come and combine the this to file know... Sir
@narmatharamasamy3019
@narmatharamasamy3019 3 жыл бұрын
Its only for variables, not for functions, functions doesn't need an extern keyword
@sahilpatil8287
@sahilpatil8287 3 жыл бұрын
@@narmatharamasamy3019 thanks dude you just solve my doubt👍👍
@sathvikswaminathan7933
@sathvikswaminathan7933 4 жыл бұрын
How is your program running without errors since you have not included add.c in your main.c file?
@fortnitelove8129
@fortnitelove8129 4 жыл бұрын
Absolutely i had the same qn. Actually he is using codeblocks IDE , and it has a feature if all the .c files are under same project directory,than no need to explicitly declare the add.c file in main ()
@pratishthachaurasia6326
@pratishthachaurasia6326 6 жыл бұрын
Auto variables are given garbage values if not initialized with a value. By default, variables are auto variables. Is a global variable, not an auto variable? And if not initialized, does it get garbage value or 0 by default?
@zakirahimi7924
@zakirahimi7924 4 ай бұрын
static variable is not global (though it can declared globally in a file then it is accessible to all the blocks and functions of that file) it is local to the block of code where it is declared or within the function its declared, its lifetime is throughout the program even if it is declared local to a block of code. ""this is the example of a variable is alive but not accessible""
@adithyagalipelli2934
@adithyagalipelli2934 3 жыл бұрын
How are we accessing the "count" in main.c without using the extern modifier?
@chandubadam2773
@chandubadam2773 2 жыл бұрын
We can't access it without using extern modifier..
@girishsuraskar1514
@girishsuraskar1514 2 жыл бұрын
how make that project file in vs code ide...plz help me😢😢🙏🙏
@ganeshrajavaddi8036
@ganeshrajavaddi8036 3 жыл бұрын
static int count =3; even you assigning 3 to it and calling 3 times how still output 6? Even you calling 3 times why it's not re assigning 3 every time??
@ZeeshanAliQureshi93
@ZeeshanAliQureshi93 3 жыл бұрын
Getting this warning: warning: implicit declaration of function 'increment' [-Wimplicit-function-declaration]
@someshm.1405
@someshm.1405 3 жыл бұрын
I'm getting - [error] 'increment' was not declared in this scope. Plz help
@nazninhaque
@nazninhaque 3 жыл бұрын
plz start electrical machines and engineering mathematics courses also
@harshitchauhan2531
@harshitchauhan2531 2 жыл бұрын
sir vs code doest support this type of declaration
@iamarpit.sharma
@iamarpit.sharma Жыл бұрын
Use #include "add.c"
@Dontever_throw_trash_out
@Dontever_throw_trash_out 5 жыл бұрын
it rather looking like an assembly language code
@sumansaha8042
@sumansaha8042 5 жыл бұрын
sir if I don't comment on extern int count; its still giving me the same answer. the code is running sucessfully without any error and the answer is 3. why??
@senthilnarayanan5481
@senthilnarayanan5481 5 жыл бұрын
If you try to print count the it shows error.
@mamtagrewal7136
@mamtagrewal7136 3 жыл бұрын
I'm not getting do you want to add this file to project in vs code anyone plz help
@pritisharaychaudhuri9449
@pritisharaychaudhuri9449 3 жыл бұрын
He is using codeblocks.
@pritisharaychaudhuri9449
@pritisharaychaudhuri9449 3 жыл бұрын
Files will be created under one project.
@anandpriyanshu9110
@anandpriyanshu9110 2 жыл бұрын
Use #include "file name"
@peymant2341
@peymant2341 2 жыл бұрын
how come when you return "count" it doesnt get set to 0 again " int count = 0;" and "int count; are the same "
@stephenhemingway9435
@stephenhemingway9435 7 ай бұрын
I have the same question.
@animasinghdhabal5052
@animasinghdhabal5052 5 жыл бұрын
Sir..as u said in d previous lectures dat we cant use same variable name within d same block.. isn't it?? Den how come we are using " value=increment()" 3 tyms..
@sushmitaraj6948
@sushmitaraj6948 5 жыл бұрын
he said that we cant define more than once, here he is just updating the old value to new value
@marksladen2901
@marksladen2901 4 жыл бұрын
// This program fails to compile: #include int main(int argc, char* argv[]) { // declare the variable 'value' int value = 0; // print the variable 'value' printf("%d ", value); // attempt to define the variable a second time int value = 7; //
@srikarrepaka5023
@srikarrepaka5023 3 жыл бұрын
10:30 : The global variable was never destroyed 18:00 : static should be only initialized by constant not a variable 18:11
@ganeshrajavaddi8036
@ganeshrajavaddi8036 3 жыл бұрын
static int count =3; even you assigning 3 to it and calling 3 times how still output 6? Even you calling 3 times why it's not re assigning 3 every time??
@animeaddicteduwu
@animeaddicteduwu 8 күн бұрын
wouldnt it be better to tell the properties first and then say to solve the problem so we can rack our brains
@esma2856
@esma2856 2 жыл бұрын
17:56 my code worked😅why?
@ajmalkhaniit
@ajmalkhaniit 4 жыл бұрын
Please increase your voice volume!
@priyankamaran7244
@priyankamaran7244 5 жыл бұрын
I'm getting 4 errors : Undefined reference to 'increment' please help!
@hrithikjaysingpure9623
@hrithikjaysingpure9623 4 жыл бұрын
Same here
@adilansari8414
@adilansari8414 4 жыл бұрын
Same here please help
@monikaparmar2061
@monikaparmar2061 4 жыл бұрын
You haven't linked both the files.
@prateek7526
@prateek7526 4 жыл бұрын
You have created project in c++ by mistake
@aniketkumre4231
@aniketkumre4231 2 жыл бұрын
@@monikaparmar2061 how to link both files plz help
@ankitkr4119
@ankitkr4119 2 жыл бұрын
nahi samjh mein aaaaya
@Nikkhil492
@Nikkhil492 3 жыл бұрын
would have been better if it was in hindi
Constants in C (Part 1)
8:43
Neso Academy
Рет қаралды 252 М.
Variable Modifiers − Auto & Extern
12:52
Neso Academy
Рет қаралды 329 М.
路飞太过分了,自己游泳。#海贼王#路飞
00:28
路飞与唐舞桐
Рет қаралды 35 МЛН
Каха заблудился в горах
00:57
К-Media
Рет қаралды 9 МЛН
Best Toilet Gadgets and #Hacks you must try!!💩💩
00:49
Poly Holy Yow
Рет қаралды 21 МЛН
Pointers and dynamic memory - stack vs heap
17:26
mycodeschool
Рет қаралды 1,4 МЛН
C# Async/Await/Task Explained (Deep Dive)
24:22
Raw Coding
Рет қаралды 395 М.
Static for Classes and Structs in C++
9:12
The Cherno
Рет қаралды 347 М.
why do void* pointers even exist?
8:17
Low Level Learning
Рет қаралды 343 М.
C Programming (Important Questions Set 2)
6:10
Neso Academy
Рет қаралды 525 М.
Understanding and implementing a Hash Table (in C)
24:54
Jacob Sorber
Рет қаралды 347 М.
Functions in Python are easy 📞
10:38
Bro Code
Рет қаралды 432 М.
String In Char Array VS. Pointer To String Literal | C Programming Tutorial
9:58