Variable Modifiers − Auto & Extern

  Рет қаралды 349,213

Neso Academy

Neso Academy

Күн бұрын

Programming & Data Structures: Auto and extern variable modifiers in C programming.
Topics discussed:
1. Auto modifier.
2. Extern modifier.
3. Extern modifier examples.
4. Procedure to create a project and different files within that project.
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...
Memberships: bit.ly/2U7YSPI
Books: www.nesoacademy...
Website ► www.nesoacademy...
Forum ► forum.nesoacade...
Facebook ► goo.gl/Nt0PmB
Twitter ► / nesoacademy
Music:
Axol x Alex Skrindo - You [NCS Release]
#CProgrammingByNeso #CProgramming #VariableModifiers

Пікірлер: 210
@arundhutimukherjee1412
@arundhutimukherjee1412 4 жыл бұрын
When I will pass college and get a job I will donate to Neso academy from my first salary. Thank you for your priceless efforts.
@shashinegative9366
@shashinegative9366 2 жыл бұрын
They don't need they have enough now..
@VaishnaviBasalingwar
@VaishnaviBasalingwar Жыл бұрын
good idea @@shashinegative9366
@tufandas9065
@tufandas9065 Жыл бұрын
hi where are you from??
@opgamerz877
@opgamerz877 8 ай бұрын
You'll forget bro
@ratnapalshende3052
@ratnapalshende3052 2 ай бұрын
Have you got any job ?
@vandarkholme442
@vandarkholme442 4 жыл бұрын
clear and straightforward, better than my professor
@Ribulose15diphosphat
@Ribulose15diphosphat Жыл бұрын
And Wrong: 1. auto is the opposite of register. Declaring a variable as auto, prevents compiler-optimisation to turn it into a register-variable. Typically you want register-variables in inner loop, but declare variables of the outer loop first, so delare the variables for the outer loop as auto. 2. Global variables are not initialized to zero. If your system/compiler does that - nice - but the C-standards says there is garbage.
@brewedscript1014
@brewedscript1014 4 жыл бұрын
i love these lessons. It explains everything that I need to know in coding.
@nataliab.9725
@nataliab.9725 2 жыл бұрын
I am so glad I found this channel, I have been struggling to learn C for 2 years and now I'm finally understanding it! Thank you so so much!
@bhaweshsharma275
@bhaweshsharma275 3 жыл бұрын
I'm actually getting better in C and also in DSA with this course. ❣❤💛🧡
@aniketdas451
@aniketdas451 3 жыл бұрын
honestly, this channel needs more and ultimate support. thank you, sir.
@gauravkumeriya376
@gauravkumeriya376 3 жыл бұрын
such a clear explaination ...thats the reason i always loved neso academy
@mohammedabood9877
@mohammedabood9877 2 жыл бұрын
what an amazing and smooth way of explaining, thank you so much for your effort
@Jeremyak
@Jeremyak 8 ай бұрын
These lessons are a cut above the typical tutorial fare, these go slightly deeper into the mechanics of the language and I very much appreciate that. 👍
@MohitK96
@MohitK96 6 жыл бұрын
I was taught C language just to pass exam in first year in my coaching, though college teachers came occasionally... Now, I came to this tutorial, I already did DE tutorials from Neso, amazed to know so many things, wished Neso had uploaded it earlier...
@UniversalSaad
@UniversalSaad 2 жыл бұрын
My exam is knocking at the door. Your lecture keeping me fight like a survivor. Thanks a lot, sir. All my respect for you. ♥
@李睿恩-f5x
@李睿恩-f5x 3 жыл бұрын
I'm the student from taiwan , this lesson help me a lot in learning c , Just keep going , you already change the way the cs student around the world how to study. Thank you !!!!
@KarasuOfficial-g9v
@KarasuOfficial-g9v 8 ай бұрын
As a turkish student, Hand me over to the Indian educators.
@dipeshsamrawat7957
@dipeshsamrawat7957 4 жыл бұрын
Thank you so much, I will never forget you. Thank you so much again and again. ☺️☺️☺️❤️❤️❤️❤️🙏
@ashokkoli9977
@ashokkoli9977 3 жыл бұрын
You definitely deserve more subscribers!!🙌
@akshatnitnaware9940
@akshatnitnaware9940 5 жыл бұрын
Really good Explanations, god bless you!
@anandkumarsinghCS
@anandkumarsinghCS 3 жыл бұрын
Yes after paying on, you will have not too much better tutorial 👍👍👍👍
@nikhilagrawal9217
@nikhilagrawal9217 5 жыл бұрын
Thank you so much for making this video. It was worth seeing this video 😀😃
@galnadjar
@galnadjar 3 жыл бұрын
simply precise and clear. thank you so much !
@MikeOchtman
@MikeOchtman 3 жыл бұрын
Very clear description. Thank you very much!
@sadia.shafaque
@sadia.shafaque 4 жыл бұрын
Beautifully explained, thanks alot!
@nisargsheth9841
@nisargsheth9841 5 жыл бұрын
Thank you very much. simple and crisp lecture.
@SHASHANKRUSTAGII
@SHASHANKRUSTAGII 4 жыл бұрын
helpful. Thanks NESO, I love you guys
@Pilgrim182
@Pilgrim182 4 жыл бұрын
Very clear explanation Sir, thank you.
@cucuccucuc3744
@cucuccucuc3744 3 жыл бұрын
These lectures are just costless
@astasuleo
@astasuleo 5 жыл бұрын
amazing thanks so much for these lessons.
@vakhariyajay2224
@vakhariyajay2224 3 жыл бұрын
Thank you very much. You are a genius. 👍👍🔝🔝
@OAOOHarikesavareddy
@OAOOHarikesavareddy 3 жыл бұрын
best course ever...i loved it
@MJ-dq8om
@MJ-dq8om 4 жыл бұрын
at 1:43 , I haven't initialized a variable in main function and by printing that variable,it gave me as 0 but not a garbage value.
@krutarthpatel6537
@krutarthpatel6537 4 жыл бұрын
Very nice video 🔥🔥
@_MostofaShariarSanim_B
@_MostofaShariarSanim_B 4 жыл бұрын
To be honest , this course is better than some paid course.
@Official-tk3nc
@Official-tk3nc 5 жыл бұрын
Guys they are providing everything for free and some idots dislikes these types of videos. I think they need mental treatment
@sagnikpoddar881
@sagnikpoddar881 4 жыл бұрын
they are unaceademy employess
@Leo-qr1rq
@Leo-qr1rq 3 жыл бұрын
Chill bro it's bot,which was programmed by KZbin
@corsicanbread7276
@corsicanbread7276 3 жыл бұрын
They probably got mad they couldn’t figure it out or something
@shreyajha7097
@shreyajha7097 4 жыл бұрын
Thank you so much for making such videos. These are very helpful and easy to understand 😊😊
@TheFactsThatShowYouWise
@TheFactsThatShowYouWise 3 жыл бұрын
your expletation is quite magnificent
@atharvanaik2434
@atharvanaik2434 4 жыл бұрын
GCC didn't compile program with auto keyword. It throws error:two or more data types in declaration of 'var'. While, cl(MSVC) printed 0.
@oggy107
@oggy107 4 жыл бұрын
Best one you can get😍
@mukulmalviya1605
@mukulmalviya1605 3 жыл бұрын
use of uninitialized local variables leads to undefined behaviour. It depends on the compiler, in the visual studio community if we print the value of uninitialized variable it gives compile-time error while in GCC compiler it prints 0
@csharpdev-software-engineer
@csharpdev-software-engineer 3 жыл бұрын
👍👍👍 thanks for good tutorial!
@prabhatatha8968
@prabhatatha8968 4 жыл бұрын
Awesome tutorial to learn c programming
@krut4rth
@krut4rth 10 ай бұрын
@2:35 int var; // It is just declared, not defined.. // definition is when you assign memory to it with = operator
@mauryaashish1865
@mauryaashish1865 4 жыл бұрын
Awesome explanation!!
@himanshuyadav1712
@himanshuyadav1712 2 жыл бұрын
Thanku you sir. 🙏🙏🙏🙏🙏🙏
@jayasmitade7474
@jayasmitade7474 2 жыл бұрын
Short and to the point videos, finally I found the course I needed. Thank you so much for all your effort. _/\_
@snitabongale7823
@snitabongale7823 Жыл бұрын
Very helpful video
@md_daud
@md_daud 2 жыл бұрын
Thank you ❤️
@balajishanmugavel1861
@balajishanmugavel1861 3 жыл бұрын
Thanks neso academy
@sayanmondal1387
@sayanmondal1387 3 жыл бұрын
sir extern int a; doesn't work in my code blocks what should I do? my main.c #include extern int a; int main() { printf("%d", a); return 0; } and my other.c int a = 56;
@saiprasadjetti2175
@saiprasadjetti2175 5 жыл бұрын
Excellent lecture
@rashidshah277
@rashidshah277 7 жыл бұрын
Excellent way of Teaching !!!
@ojasvvgupta5639
@ojasvvgupta5639 3 жыл бұрын
at 9.52 even if we dont write extern in main then also it will print 9 as we have already defined the global variable then why to use extern.
@zizomohamed9015
@zizomohamed9015 2 жыл бұрын
Thank you for a wonderful video and a great explanation.
@deepayanbiswas4488
@deepayanbiswas4488 3 жыл бұрын
Very good tutorial, tysm.
@tezlallc2900
@tezlallc2900 3 жыл бұрын
At 8:41 on Video 14 (Variable Modifier - Static) you place a variable outside the scope of any function and specifically call it global. Thus it retains its value and should be accessible to main which is within a completely different file. If this is true then why the need for extern? It appears to me that you cannot compile when you delete the line extern within main here in this video which seems to suggest just the opposite of Video 14 which is to say that int a= 5; is NOT really global after all.
@Atsushi549
@Atsushi549 5 ай бұрын
9:41 , do we still need to use extern int for accessing global variable?
@sudipkumarmondal136
@sudipkumarmondal136 4 жыл бұрын
Sir, in my computer auto variable does not give garbage values it also initializes with 0 as same as global variable.
@mateuszlukaszczyk5359
@mateuszlukaszczyk5359 4 жыл бұрын
Thanks for the great content.
@akritibhan5858
@akritibhan5858 3 жыл бұрын
simply awesomeeeee.....
@lakshmimanasamanasa5052
@lakshmimanasamanasa5052 2 жыл бұрын
@7:28 -> external variable declared is a global variable for that file right? All the global variables are by default initialized to 0, isn't it? why don't it give the output as 0 and instead giving an error?
@sruthimajhi5610
@sruthimajhi5610 2 жыл бұрын
Great one sir!
@avitiwari7921
@avitiwari7921 3 жыл бұрын
Good Explanation What if there are multiple files with int a declaration and defination and a single extern int a in main file? If memory is not provided to extern int a, so when does the exact value and memory for variable a is filled?
@karthikbankapur3520
@karthikbankapur3520 5 жыл бұрын
sir I had tried to print output for an integer(not initialized) but instead of printing any random garbage value it prints 0 all the time. why so?
@vineetverma6645
@vineetverma6645 4 жыл бұрын
was it global?
@riturajpathak1905
@riturajpathak1905 4 жыл бұрын
same and it was not global
@princedhiman8714
@princedhiman8714 4 жыл бұрын
@@riturajpathak1905varies according to machine properties
@gauravkumeriya376
@gauravkumeriya376 3 жыл бұрын
@@riturajpathak1905 ya but it is unpredictible in latest version of gcc. see geeks for geeks
@parsikarudhirbabu9462
@parsikarudhirbabu9462 3 жыл бұрын
it happened for me too
@vikassaini1935
@vikassaini1935 4 жыл бұрын
this is gold
@prasadsawant9122
@prasadsawant9122 4 жыл бұрын
Thanks for sharing so many small small details , not only for this topic but all topics in all of your videos ... I do have one question here for extern What if we declare int a = something in two different files and try to refer in our main file using extern ..which one it will refer?
@compangit1524
@compangit1524 2 жыл бұрын
I will just leave a comment for myself. Feel free to comment, thanks. Global variables are initialized to 0 by default. Extern is short for external. It declares the variable but no definition (though you can also define it), therefore no memory allocated to it. This is used when we want access a variable of the same name but located and defined in the nearest outer scope which can also include other files in the current workspace. It avoids redifinition or having to find another variable name for the same variable. Autos can't be declared multiple times, but externs can be. Declaration then definition. Initialize == define.
@saiprasadjetti2175
@saiprasadjetti2175 5 жыл бұрын
Nice explanation
@Sabari-gd3fw
@Sabari-gd3fw Жыл бұрын
Hi sir, Thanks for this useful content. I have one query in this , at 10:03 you told if extern variable don't have definition in current file, it will go and search other files to retrieve the definition..my question here is which file it takes first to search the definition of this extern variable...because in your case you have created only one "other.c" file...but in reality there are lot of files will be there.If I am varying that extern variables in multiple files which file definition it will consider first?
@adeebhamidy7564
@adeebhamidy7564 2 жыл бұрын
better than my professor and his slides😅
@agamgill9563
@agamgill9563 7 жыл бұрын
informative lecture....thanx sr...
@chiragchirag4649
@chiragchirag4649 6 ай бұрын
Will these concepts of system level features be used in other programing language like python?????????
@shubhampawar.7776
@shubhampawar.7776 3 жыл бұрын
Masterpiece
@JohnWick-el6ck
@JohnWick-el6ck 4 жыл бұрын
Aaj mere deemag ko bahot jada shanti mili
@sharau.99
@sharau.99 4 жыл бұрын
You are excellent !!!
@cloudproblemssolved
@cloudproblemssolved 8 ай бұрын
amazing
@shiprajha8304
@shiprajha8304 4 жыл бұрын
when i keep the variable global and uninitialized, its showing compilation error and for local variable (not initialized) its showing 0 and not garbage value....why is that?
@Jkt61205
@Jkt61205 4 жыл бұрын
JUST AMAZING!!
@anupriyarani6902
@anupriyarani6902 4 жыл бұрын
Sir then What is the use of auto modifier ,if it doesn't change anything in program.
@conceptual3053
@conceptual3053 4 ай бұрын
Full doubt clearance channel
@shrutimishra9809
@shrutimishra9809 4 жыл бұрын
Please anyone tell me,are these lectures are enogh for gate 22 ..please.
@frezajoe5836
@frezajoe5836 3 жыл бұрын
now, what is the pros of external keyword, if we can just include one file in another in order to access his declared globale variable instead of those geeky flashy gamic extern keyword?
@Zer0_byte
@Zer0_byte Жыл бұрын
dear sir i try it what i notice is when i auto char auto float is value is expect 0 also unsigned int
@panthasaleheen4952
@panthasaleheen4952 5 жыл бұрын
What I think is, the extern variable works like the complement set. 'A' complement is equal to universal set minus 'A' set.
@hibmoshar6206
@hibmoshar6206 10 ай бұрын
thanks alot
@someshkharat5667
@someshkharat5667 3 жыл бұрын
By completing this course I will be master in c language 😈😈😅
@akshadrathod9203
@akshadrathod9203 Жыл бұрын
nice one
@RiseAayush
@RiseAayush 3 жыл бұрын
The output when i use var in form of global variable as well as in the scope gives the output as same as 0. What would be the reason behind it????????
@ProProgrammer-ss4gb
@ProProgrammer-ss4gb 9 ай бұрын
Are the notes of these lectures available somewhere...? And how can i access them...?
@omkumarsingh4194
@omkumarsingh4194 3 жыл бұрын
If I define variable int a =3; inside some function say func() then , I write extern int a; in main() and printf ("%d",a); Whether it will show 3 or error.
@abhaypratap9898
@abhaypratap9898 3 жыл бұрын
Error
@himanshichoudhary8778
@himanshichoudhary8778 4 жыл бұрын
Thanks
@techbeginners3816
@techbeginners3816 3 жыл бұрын
1:44 sir what is garbage value and how it is printed?
@namitasharma5201
@namitasharma5201 4 жыл бұрын
can't thank you enough
@JE-SyedAteebShah
@JE-SyedAteebShah 3 жыл бұрын
Does [extern int var] always need to be a global variable???????
@yagneshacharya2461
@yagneshacharya2461 2 жыл бұрын
what if we create more than 2 files like i created 3 files and declaring int a = 2 and int a = 3 , and then i write extern int a in my 1st file , so when i write printf(a) what will print?
@harshbhadani537
@harshbhadani537 3 жыл бұрын
In my project there is not any (other.cpp) file what should i do to add that.
@dachinoloko7624
@dachinoloko7624 3 жыл бұрын
Hi thanks for the lessons I appreciate it very much. However, I have a question. I tried not intializing my variable with int var; and also with auto int var; where both are actually the same in the local scope. The result I obtained was zero instead of indeterminate/random/garbage value. Why is that so? This means the int var; in local is the same as if I declare it globally since int var; in global is always zero. Thank you and hope to hear your explanation when you're free. Cheers!
@Daisy-xs9yb
@Daisy-xs9yb 3 жыл бұрын
int var in local getting zero is not the same as int var in global because when you declare a global variable the initial or the default value is zero but a local variable stores a random number so if you get a local variable equal zero then it is just a coincidence maybe if u give local int var another time it will give a diff ans. hope it helps
@destinyobamwonyi8865
@destinyobamwonyi8865 Жыл бұрын
if you are a nerdy nerd like my self and you are using vim or emacs you can access the variable by compiling the two files, like this "gcc main.c other.c -o main". where main is the executable.
@jaisuriyar5259
@jaisuriyar5259 3 жыл бұрын
but I am getting this error for extern: collect2.exe: error: ld returned 1 exit status
@esma2856
@esma2856 2 жыл бұрын
10:00 I wrote the same as you wrote (int a = 5; in the file "other.c") but I got the error. Error is:multiple definition of 'a'. Why did this happen? And how can I fix it?
@clementnathanael3085
@clementnathanael3085 2 жыл бұрын
u use vscode or what?
@arbajkhan042
@arbajkhan042 Жыл бұрын
​@@clementnathanael3085 vs code
@dr.anubhavkumarprasad5765
@dr.anubhavkumarprasad5765 4 жыл бұрын
extern int a=10; extern int a; //do not have this name variable in any other file Above code do not produce error. Multiple declaration is allowed which is ok, but second line is linking to variable in same scope ?
@snehchauhan8507
@snehchauhan8507 4 жыл бұрын
Yes exactly. By writing extern int a=10; it means both declaration and definition
@mathematics_rajkumar
@mathematics_rajkumar 3 жыл бұрын
For me 'auto int var' giving 0 as output, when I won't initialize var, is garbage value?
@puneetkorjani6648
@puneetkorjani6648 3 жыл бұрын
but when i don't initialize the auto variabe still it is showing 0 value not any garbage values??
Variable Modifiers − Register
4:02
Neso Academy
Рет қаралды 213 М.
Global Variables in C++... not as easy as it seems
18:25
The Cherno
Рет қаралды 68 М.
Fundamental Data Types − Float, Double & Long Double
13:06
Neso Academy
Рет қаралды 373 М.
Variable Modifiers − Static
19:02
Neso Academy
Рет қаралды 254 М.
Learn Any Programming Language In 3 Hours!
22:37
Code With Huw
Рет қаралды 649 М.
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 856 М.
Mastering Dynamic Programming - How to solve any interview problem (Part 1)
19:41
Scope of Variables - Local vs Global
11:12
Neso Academy
Рет қаралды 423 М.
Templates in C++
17:58
The Cherno
Рет қаралды 612 М.
Constants in C (Part 1)
8:43
Neso Academy
Рет қаралды 268 М.
Fundamental Concepts of Object Oriented Programming
9:16
Computer Science Lessons
Рет қаралды 997 М.
Writing Code That Runs FAST on a GPU
15:32
Low Level
Рет қаралды 581 М.