Static Variables In C: C Tutorial In Hindi #42

Поділитися
Вставка
  • Опубліковано 7 вер 2024
  • In this series of C programming tutorial videos, I have explained you everything you need to know about C language. I hope you are enjoying this C course in Hindi.
    ►This C Lecture is a part of this C Programming Course: • C Language Tutorials I...
    ►Source Code + Notes: codewithharry....
    ►Click here to subscribe - / @codewithharry
    Best Hindi Videos For Learning Programming:
    ►Learn Python In One Video - • Learn Python In Hindi ...
    ►Learn JavaScript in One Video - • JavaScript Tutorial
    ►Learn PHP In One Video - • Learn Php In One Video...
    ►Machine Learning Using Python - • Machine Learning Tutor...
    ►Creating & Hosting A Website (Tech Blog) Using Python - • [Hindi] Web Developmen...
    ►Advanced Python Tutorials - • Intermediate/Advanced ...
    ►Object Oriented Programming In Python - • Object Oriented Progra...
    ►Python Data Science and Big Data Tutorials - • Python Data Science an...
    Follow Me On Social Media
    ►Website (created using Flask) - www.codewithha...
    ►Facebook - / codewithharry
    ►Instagram - / codewithharry
    ►Personal Facebook A/c - / geekyharis
    Twitter - / haris_is_here

КОМЕНТАРІ • 169

  • @CodeWithHarry
    @CodeWithHarry  5 років тому +98

    C programming ke is course ke end mei konsa project banaye? Any suggestions?

    • @chandan1980-s8z
      @chandan1980-s8z 5 років тому +22

      Hacking using C

    • @tejasjani2544
      @tejasjani2544 5 років тому +6

      Html parser ka solution kaha he sir

    • @tejasjani2544
      @tejasjani2544 5 років тому +4

      HTML parser program link: drive.google.com/file/d/1f9QvEGdmkYjqydd2PuQsZJ82M-mn_Z-7/view?usp=drivesdk
      Sir mera program sahi he kya reply me

    • @tejasjani2544
      @tejasjani2544 5 років тому +5

      Sir project graphics base banana he ya console based ?

    • @omnish22
      @omnish22 5 років тому +2

      Aur bhaiya me anaconda use krta hoo uske saath vs code...to apke environment wali video wale commands anaconda se bne environment ko activate ni kr pa rhe he aur bhi bahot problem ho rhi he kya aap please un sbka solutiot bta skte ho

  • @RohanSaluja
    @RohanSaluja 3 роки тому +43

    This Playlist is still the best and will be the best for a Long time!...

  • @mohammedilyazkhan5425
    @mohammedilyazkhan5425 3 роки тому +15

    In this video
    the global variable has declared outside of the main( ) function

    • @Zeeshan0746
      @Zeeshan0746 11 місяців тому

      I was thinking the same😅

  • @amishpratapsingh1977
    @amishpratapsingh1977 3 роки тому +11

    this video was a little bit lengthy considering the logic explained......
    loved it tho..

  • @atifmalik8012
    @atifmalik8012 5 місяців тому +1

    #include
    int func()
    {
    static int age=0;
    age ++;
    printf("The age is %d
    ",age);
    }
    int main(){
    printf("At birth:-
    ");
    func();
    printf("After 1 year
    ");
    func();
    printf("After 1 year
    ");
    func();
    }

  • @EasyMathematics01
    @EasyMathematics01 2 роки тому +9

    example of local gunda is awesome.😀

  • @ronycb7168
    @ronycb7168 15 днів тому

    Finally the realisation hit me that I should make notes only gonna watch with a note with me from now on. Great work Bhaiyya but HTML parser seems a bit tough for me but I'm trying it anyway.. Also in this I think you didn't go into detail about functions I'm trying to put user defined functions inside another user defined its not going well thx for this free course will spread the word once I finish the course and start to master C this course was the one that finally gave me confidence that I can pick up C lang I have 2 books on C but nothing helped me till I started this course .

  • @Sammy13
    @Sammy13 4 роки тому +21

    No one:
    Harry Bhai : mujhe ghumao mat XD

  • @sachinsinghal3535
    @sachinsinghal3535 Рік тому +4

    difference between static global variable & normal global variable in c.
    difference between static function & normal function in c?

  • @thorsendh6948
    @thorsendh6948 3 роки тому +4

    very nice, understood for the first time

  • @starkendeavours7072
    @starkendeavours7072 3 роки тому +6

    Can u explain why the function is not returning b1 + myvar ; ? It must return because value of b =344 is passed to b1
    And at last of fun1( ) it's written return b1 + myvar. ???

    • @anubhav1020
      @anubhav1020 3 роки тому +11

      It will be printed if func1 is used within printf.
      Like:
      printf("The value returned from func1 is %d
      ", func1);
      Then Output will be:
      The value of myvar is 0
      The value returned from func1 is 344
      Hope it is clear now !

    • @edwardellis7788
      @edwardellis7788 Рік тому

      @@anubhav1020 Can u pls explain why its like that...Its returning the entire value b1+myvar. So it should store that full value in val right?

    • @Lack_Of_Enemies
      @Lack_Of_Enemies Рік тому +1

      ​@@edwardellis7788yeah, it is storing. He just isn't printing val in the video.

    • @Zeeshan0746
      @Zeeshan0746 11 місяців тому

      ​@@edwardellis7788yes, if you will print val, you will get what you are looking for.

  • @tapans2998
    @tapans2998 5 років тому +8

    Why B1+myvar is not returning when function is being called?

    • @anubhav1020
      @anubhav1020 3 роки тому +2

      It will be printed if func1 is used within printf.
      Like:
      printf("The value returned from func1 is %d
      ", func1);
      Then Output will be:
      The value of myvar is 0
      The value returned from func1 is 344
      Hope it is clear now !

    • @shaharslan3372
      @shaharslan3372 3 роки тому +1

      @@anubhav1020 but what is you typed is returning a garbage value.

  • @samarjeetdangi4297
    @samarjeetdangi4297 2 роки тому +4

    harry sir u are great😘🙌🙏

  • @NoBoDy-yi4eo
    @NoBoDy-yi4eo Рік тому +1

    i didn't understand the " return b1 + myvar; " line. can anyone explain this , please??
    int func1( int b1)
    {
    static int myvar=0;
    printf("The value of myvar is : %d
    ", myvar);
    myvar++;
    return b1 + myvar;
    }

  • @AaravDecodes
    @AaravDecodes 5 років тому +9

    Sir C language ke baad data structure please 🙂🙂

  • @pratikkurade1270
    @pratikkurade1270 3 роки тому +14

    AOT people watching this in 2021 be like "my var".

  • @royfamily9273
    @royfamily9273 2 роки тому +1

    Thanks Harry Bhaiya

  • @funnyvideotitk7349
    @funnyvideotitk7349 Рік тому +1

    func1() last me return kar raha hai `b1+myvar` okay. Then, in main() b = 344; Then why return the 98, 99, 100. instead of (344+98)=442,443 and so on. Please help regarding this

    • @--kakashi
      @--kakashi Рік тому +1

      b1 + myvar return to ho rahe hai par wo main() function main kahin bhi print nhi ho rahe hai.
      par func1() main sirf myvar print ho raha hai isliye sirf myvar ki value increment hokar printf ho rahi hai.

    • @--kakashi
      @--kakashi Рік тому

      agar ye function printf ke andar likha hota to b1 + myvar print hota.

  • @gauravchaudhari9401
    @gauravchaudhari9401 3 роки тому +2

    Bhohot Achha Samjaye Harry Bhai...

  • @atifmalik8012
    @atifmalik8012 5 місяців тому

    //here a is local variable of func() so we can not access it in main ()
    //now b is global variable as it is declared outside any function we can access it anywhere but it is not proffered because the memory is occupied even if it is not in use
    // int c is formal parameter of func and c is actual parameter now if c is declared as global parameter then local value of c is prefferd first and it is print on output
    #include
    int b = 10;
    int c = 15;
    int func(int c){
    int a = 4;
    printf("%d
    ",b);
    printf("%d",c);
    }
    int main() {
    int c =3;
    //printf("%d",a);
    printf("%d
    ",b);
    func(c);
    }

  • @wasifnadeem6209
    @wasifnadeem6209 2 роки тому +2

    In func1 function, what return b1 + myvar does, Harry bhai!?

  • @aviralsaxena9773
    @aviralsaxena9773 2 роки тому +2

    5:34 harry bhai and selmon bhoi😂😂

  • @priyanshuworld
    @priyanshuworld 2 роки тому +1

    When i daclare the static function and putting the value after the declaration it print different
    Static int a ;
    a = 0 ; then it print same

  • @khushiyoutubechannel6193
    @khushiyoutubechannel6193 2 роки тому +1

    it is very helpful thanks harry bhai..

  • @kanhakhushigupta7786
    @kanhakhushigupta7786 4 роки тому +3

    Wwooowww I completed 42 videos 😵😵😵😱😱😱💖💖💖

    • @starkendeavours7072
      @starkendeavours7072 3 роки тому

      Can u explain why the function is not returning b1 + myvar ; ? It must return because value of b =344 is passed to b1
      And at last of fun1( ) it's written return b1 + myvar.

    • @shwetankjoshi3011
      @shwetankjoshi3011 2 роки тому

      @@starkendeavours7072 bro if u have got the ans until now , so plz tell me

  • @ompaltomar8418
    @ompaltomar8418 5 років тому +3

    HARRY bhai A.I ki series chahiye

  • @shrikrishnaumbare
    @shrikrishnaumbare 3 роки тому

    Baap of cmputer language 😎😎like the best teacher for coding

  • @nadirraza7970
    @nadirraza7970 5 років тому +2

    Thank you so much sir. very helpful video.
    sir meri php ki problem solv nahi karai sir aapne . please help me . sir phele bhi aapse phucha tha maine.
    sir php ke problem ye hai ki ek blog post me jb user comment ya like karta hai to with out user ke name and gmail ke like or comment nahi honi chahiye .sir ek blog post ki class karado na sir please help me .

  • @NitinKumar-qk1fi
    @NitinKumar-qk1fi 4 роки тому +2

    Bilkul smjh me agya bro

  • @Goku-ir1sy
    @Goku-ir1sy 4 роки тому +2

    You teach very well.

  • @asmitapatil5266
    @asmitapatil5266 3 роки тому +4

    Great 👏👏👏😍😍

  • @readingradiance1
    @readingradiance1 3 роки тому +1

    Thanks for your support sir

  • @ASHWATTHAMORE
    @ASHWATTHAMORE 5 місяців тому +1

    Please try to keep things clean. Sometimes you just comment out and that's where things get confusing. Remember bro we are beginners and if you do things in code so quickly we would get confused.

  • @gunjanagrawal8626
    @gunjanagrawal8626 3 роки тому +8

    //global variable, g1=7;
    //local variable ,g1=3;
    Does this mean that the value of global variable has modified to 3 from 7?

    • @syedrashidali4469
      @syedrashidali4469 3 роки тому +1

      no

    • @SadhguruKnows
      @SadhguruKnows 2 роки тому

      No it depends on how u use them. For example, I have local g1=3 & global g1=7 &
      if I am calling the function in which local g1=3 exists, then the value g1=3 will be considered, and if it doesn't exist then global variable g1=7 will be considered

    • @SKD14344AK
      @SKD14344AK 9 місяців тому

      so what about precedence of C language cause harry sir use the word precendence and in previous lecture harry sir told about the precedence it actually works like the handling of condition with the help of associativity @@SadhguruKnows

    • @SKD14344AK
      @SKD14344AK 9 місяців тому

      @@SadhguruKnows according to me it actually works on the basis of precedenc

  • @codificatore_05
    @codificatore_05 8 місяців тому

    At 19:44 it will be This is a global variable since it is declared outside main() . Please audience rectify the mistake. Thank You

  • @ruturajgavade7555
    @ruturajgavade7555 Рік тому +3

    Sir, Program type karne ke liye logic kaise lagaye?

  • @SanjayYadav-by4ie
    @SanjayYadav-by4ie 11 місяців тому

    I am watching c language in 2023 sir you have ossame explain whole c laguage thank you so much

  • @ayanavadas6154
    @ayanavadas6154 3 роки тому +5

    Bhaiya, I feel that in this comment inside should be replace by outside.
    // This is a global variable since it is declared inside main()

    • @AhmadRizviYT
      @AhmadRizviYT Рік тому

      main ke andar variable local hote hai... saare function ke bahar global

  • @ayanavadas6154
    @ayanavadas6154 3 роки тому +1

    Enjoying the video series till now.

  • @pateljoy629
    @pateljoy629 4 роки тому +5

    Great work :)

  • @Rajput-dd8fe
    @Rajput-dd8fe Рік тому

    Local variable:Sachin kumavat
    Global variable: BTS
    😅😅 Right sir?
    Please reply on it sir
    Is it am I right or not....

  • @Agroot0
    @Agroot0 Рік тому +1

    explain, why output is not showing the value of ....return b1+myvar

  • @mahiratlover3971
    @mahiratlover3971 3 роки тому +6

    Local gunda vikas dubey kanpur Wala 😂

  • @architamishra4580
    @architamishra4580 3 роки тому +1

    Can you explain scope sir .
    Please
    I am understanding this

  • @HGODSLAYER
    @HGODSLAYER Рік тому +2

    Bro apne last me ret() ko static int me input kiya wo toh work kar raha hai
    Output:-
    129
    130
    131
    132
    133
    Ye aa raha hai
    #include
    int b = 34; // This is a global variable since it is declared inside main()
    int ret()
    {
    return 43*3;
    }
    int func1(int b1)
    {
    static int myvar = ret();
    printf("The value of myvar is %d
    ", myvar);
    myvar++;
    // printf("the value of b inside func1 is %d
    ", b);
    // printf("The address of b inside func1 is %d
    ", &b);
    return b1 + myvar;
    }
    int main()
    {
    int b = 344;
    // printf("The address of b inside main is %d
    ", &b);
    int val = func1(b);
    val = func1(b);
    val = func1(b);
    val = func1(b);
    val = func1(b);
    int *ptr = &val;
    // printf("The value of func1 is %d", val);
    // printf("%d", loc);
    return 0;
    }
    How? Apne toh kaha tha ki ret() static variable me intialize nahi hoga
    Apke me toh dikhaya ki intialize nahi hoga sirf constant literal accept karega
    Paar me wo code ko copy karke apne Cxxdroid app pe use kiya toh output aa raha hai

    • @AhmadRizviYT
      @AhmadRizviYT Рік тому +1

      mene tera code copy karke dekha aur 3 online compiler mai chalaya teeno mai error deta hai jo harry ne bataya

    • @AKSH_DESAI
      @AKSH_DESAI 8 місяців тому +1

      yes. mere me bhi output aa raha hai instead of error. because abhi rules change ho gaye hai. ab compiler static variable ko compile time me bhi value assign kar sakta hai That's why you and I also don't receive any error in this programme.

  • @Quzhisnadja128
    @Quzhisnadja128 2 роки тому

    sir apne bola ki static variables run time se oehle hi memory me store hojaate hein ....
    per sir ager koi static variable function ke ander likha ho to vo kyaa tab bhi ?? pehle memory allocate krlege ... bina program us function tak pahoche ??

  • @ImranAli-ii6dx
    @ImranAli-ii6dx 5 років тому +2

    b1 ka value assign nahi hu tha sir static define karne ke baad kyun sir???

  • @abhinavkumaar2876
    @abhinavkumaar2876 3 роки тому +2

    what if we use static variable in a union, the what will be the criteria for memory allocation?

    • @AhmadRizviYT
      @AhmadRizviYT Рік тому +2

      same jab bina static use kiye hue tha

  • @priyamane2682
    @priyamane2682 3 роки тому +2

    Sir Jaisa apne static variable me bataya ki static variable in function increment. But sir local variable increment Nahi hota hai function me when call function again again... Aisa kyon ..could u please tell me

    • @darpananand9848
      @darpananand9848 3 роки тому +1

      Yahi tooh static variables ki property hai ....ki voo apni previous value yaad rkta hai .
      LOCAL variables nhi yaad rkhte
      I hope you got it.

    • @006daredevil
      @006daredevil 3 роки тому

      Because Local variables destroy ho jaata hai function return k baad but static variables memory main save rehta hai until program execution is complete.

  • @RohanDasRD
    @RohanDasRD 5 років тому +2

    Woah.. awesome

  • @tejasjani2544
    @tejasjani2544 5 років тому +1

    Nice video

  • @BharatVicharVimarsh
    @BharatVicharVimarsh 5 років тому +2

    Plz start a course of c++

  • @vipulkumar3162
    @vipulkumar3162 3 роки тому +1

    good job harry bhai

  • @erdevkumar7
    @erdevkumar7 3 місяці тому

    Nice explanation Harry Bhai..

  • @khushiyoutubechannel6193
    @khushiyoutubechannel6193 2 роки тому +1

    💕💕💕

  • @emkaywho
    @emkaywho Рік тому

    Thanks sir

  • @Hitler_Hunter_007
    @Hitler_Hunter_007 2 місяці тому

    #include
    void func(){
    static int a=0;
    a++;
    printf(" %d day of weekend
    ",a);
    }
    int main(){
    printf("monday :
    ");
    func();
    printf("tuesday :
    ");
    func();
    printf("wednesday:
    ");
    func();
    printf("thursday :
    ");
    func();
    printf("friday:
    ");
    func();
    printf("saturday :
    ");
    func();
    printf("sunday :
    ");
    func();
    return 0;
    }

  • @Ujjwalkumar-hj1hp
    @Ujjwalkumar-hj1hp 4 роки тому +7

    Great teacher for me online

  • @nahiarabeer9565
    @nahiarabeer9565 3 роки тому +5

    Disclaimer : no gabbar singh is injured in this video
    😂😂

  • @shaharslan3372
    @shaharslan3372 3 роки тому +1

    19:25
    Outside*

  • @PrashantMilan
    @PrashantMilan Рік тому

    /* Harry bro casually drops this legendary playlist */

  • @tusharmaheshwari7344
    @tusharmaheshwari7344 2 роки тому

    harry bhai 4:48 iss pr jo screen par theme h, (high contrast + monokai) yey kesa lagay... yey batao

  • @vishalsingh1187
    @vishalsingh1187 7 місяців тому

    what about the b in the main function

  • @rosacea8016
    @rosacea8016 3 роки тому +1

    In this program , what is need of "int *ptr=&var"?????

    • @anubhav1020
      @anubhav1020 3 роки тому

      No use bro dont worry.
      &b was used to show different address of actual and formal parameters. But storing value in pointer was of no use.

  • @adityapatel6129
    @adityapatel6129 4 роки тому +2

    Harry bhai jab yaar
    Format document karta hoo na toh notification aati hai ki document formatter not installed
    So batao kaunsa formatter download kare

  • @chiteez_____1562
    @chiteez_____1562 10 місяців тому

    Very nice explanation ! ❤🔥👍

  • @PrashantMilan
    @PrashantMilan Рік тому

    Love this series

  • @suryadeep950
    @suryadeep950 4 роки тому +1

    bhai ek video bubble sort pe ho jata toh maza aa jata

  • @priyanshkumar17
    @priyanshkumar17 Рік тому

    At 3:48 , it should be void func().

    • @seesshhhh2371
      @seesshhhh2371 9 місяців тому

      Why

    • @priyanshkumar17
      @priyanshkumar17 9 місяців тому

      @@seesshhhh2371 Because the function func() doesn't return any value. It only prints the value of the global variable.

  • @salonipatil9511
    @salonipatil9511 3 роки тому

    What content are their in premium course of silver .im confuse about that

  • @DevendraSingh-zr3zq
    @DevendraSingh-zr3zq 3 роки тому +1

    amazing..

  • @abhishekbiswas2267
    @abhishekbiswas2267 3 роки тому

    Waise for global variables ko bhi for func1() nahi jhepega he will also say to give an exact value 🤔🤔

  • @saptarshiroy9824
    @saptarshiroy9824 2 роки тому

    Global variables vi kya main() k run hone se pehle run hota hai?

  • @vishalsrivastava20011
    @vishalsrivastava20011 5 років тому +2

    aage videos kb aaa rhi hai c language pe exams suru hone wale hai jldi upload kriye sirr plz plz plz plzz

  • @pavangonahal8920
    @pavangonahal8920 3 роки тому

    very nice harry sir

  • @abhiraj3477
    @abhiraj3477 5 років тому +1

    JavaScript ka course banao

  • @anshrajput3970
    @anshrajput3970 3 роки тому

    great videos bhai!!

  • @victorb22622
    @victorb22622 4 місяці тому

    10.05 ,defination की तहत तो वैल्यू इनटैक्ट रहनी चाहिए थी।

  • @zahrakhan4915
    @zahrakhan4915 3 роки тому

    Sir mera to sahi ho raha ha ?? my var k andar koi function put kr kr
    console pr output show ho rha ha

  • @rudradub7171
    @rudradub7171 Рік тому

    Local variable: gully ka chapri ;
    Global variable: you know what I'm talkin about;

  • @Sans_K5
    @Sans_K5 2 роки тому

    thanks_Sir💜

  • @pandeyfamily2812
    @pandeyfamily2812 4 роки тому +3

    harry bhai kya hum aise likh sakte hai ----- static int b = *ptr
    //is it valid syntax
    //please reply

    • @kanhakhushigupta7786
      @kanhakhushigupta7786 4 роки тому

      Aap ka statment invalid hai bro.
      Aap pointer main address ko store kar sakta ho.
      Address main variable ko store kar sakta ho .
      But, variable main address ko store nhi kar sakte 🙁😔

    • @starkendeavours7072
      @starkendeavours7072 3 роки тому

      @@kanhakhushigupta7786 Yes, you are right. It's showing Initializer element is not constant

    • @kanhakhushigupta7786
      @kanhakhushigupta7786 3 роки тому

      @@starkendeavours7072 😀☺️ thanks 🙏

  • @pinkibhowmick2342
    @pinkibhowmick2342 Рік тому +1

    Duniya pe bohut bade bade gunde h nam nehi lena chahuga ... That was epic 🤣🤣🤣

  • @adityaraj-zm7zk
    @adityaraj-zm7zk 3 роки тому

    Achha hai sir

  • @Athato_Ghumaakkad_1999Vlog
    @Athato_Ghumaakkad_1999Vlog 3 роки тому

    Sir aapka theory level programming understimte ho gaya is code ka ...but IDE par aap ke baat ka sense samajh nahi aaya...

  • @ompaltomar8418
    @ompaltomar8418 5 років тому +1

    what is CHATBOOT?

  • @swainmishra5322
    @swainmishra5322 Рік тому

    Hello sir
    Can you start cyber security if possible

  • @Om-patil_07.
    @Om-patil_07. 2 місяці тому +1

    i understand only last 15 min, topic ..😶‍🌫

  • @naammekyarakhahai2207
    @naammekyarakhahai2207 Рік тому

    Basically (Statics function) garam masala movie ka paresh wala hai 😂

  • @furygg255
    @furygg255 3 роки тому

    2:25

  • @manojpandey3318
    @manojpandey3318 2 роки тому +1

    How many are watching in the end of 2021 ?????

  • @rishabhshahimishra
    @rishabhshahimishra 3 роки тому

    Are variables pointers in c?? 🤔 Answer please

    • @shwetankjoshi3011
      @shwetankjoshi3011 2 роки тому +1

      No all pointers are variable but not all variables are pointers

  • @AnkitRaj-ys8bg
    @AnkitRaj-ys8bg Рік тому +1

    bhai ye adds🥲 or ye grammarly vala.. irrigating...

  • @FactsNarrator
    @FactsNarrator 6 місяців тому

    5:34 LOL

  • @HarshitaPandey-yj4vg
    @HarshitaPandey-yj4vg Рік тому

    kisse ko idea hai kya ki output mai number of value galat aaye to kya kare

  • @sagardahihande8158
    @sagardahihande8158 2 роки тому

  • @rosonerri-faithful
    @rosonerri-faithful 3 роки тому +2

    HarryBhai ko lag raha hell se OsamaBinLaden & Abu Bakr Al Baghdadi bhi unke videos dekh rahe hei.😂😂😂..tabhi naam nhi liya

  • @LOKENDRASINGH-ff2fi
    @LOKENDRASINGH-ff2fi 2 роки тому

    Global gunda- dawood ibrahim. 🤣🤣🤣🤣 HAARY SIR ME le leta hu naam aap nhi le skte ho , mention not 👍🏻👍🏻🤗

  • @arpandalal4731
    @arpandalal4731 3 роки тому

    yeh video me kush samaj me nahi aaya, 2-3 baar dekha, bajut fast ho gaya sab

  • @janhvinarayan1633
    @janhvinarayan1633 6 місяців тому +1

    naam nahi lena chahunga 😂😂😂😂😂🤣