C Programming Tutorial 71 - Nested For Loop

Поділитися
Вставка
  • Опубліковано 7 лис 2024

КОМЕНТАРІ • 96

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

    Just a tip for anyone who may be confused because this confused me for a long time and it is not mentioned much in many tutorials for nested for loops.
    Remember that the initial outer for loop variable maintains it's incremented variable value. The nested inner for loop resets back to the initial variable value each time it is entered. This is to do with scope.
    I had a hard time figuring this out because I would initialize two variables in the same place but run into this problem still. Hope it helps!

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

      ohmygod thank you so much

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

      Did confuse me at first. Great Point !!!!

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

      Great comment I think this has helped me figure it out better. Thanks

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

      Thank You So Much, Very Informative......!

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

      oooo gooooddd never been full of gratitude i send you all the love in my heart

  • @christypaul7348
    @christypaul7348 3 роки тому +20

    The outer loop is only used for counting the number of times the inner loop should print the print function, after every print statement in the inner loop, the program exits the inner loop and go back to the outer loop. Then the outer for loop gets initialized to i=1, now the program enters the inner loop, this time the inner for loop gets initialized to 1 instead of 0. So 1 will be printed and then due to k-- decrement, the next number will be 0, and also due to the print("/n"); at the end of inner for loop, the output will go to a new line in output console. Ask me in comments if you have any doubts, I was confused as well at first as it looks confusing.

    • @kewrie1630
      @kewrie1630 3 роки тому +3

      I am still confused, like please help i am struggling since 2 days, but still not clear about it

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

      @@kewrie1630 ua-cam.com/video/qUPXsPtWGoY/v-deo.html
      Watch this and if you still don't get it, let me know

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

      thanks! you helped me understand this one better. going step by step through the loops, and writing down every step on a paper helps understand what this 2 loops did. :)

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

    Nested? More like bested...by no other UA-cam C tutorial! Thanks again for making all of this wonderful content.

  • @mohamedkanu66
    @mohamedkanu66 4 роки тому +12

    Caleb....I must confess this is my nightmare as a beginner (nested loops - for, while or do while). So far u have helped me cement understanding of the preceding concepts. Please help with videos that carefully explain the rational for for loops, the concepts and probably numerous use cases just like in the previous lectures. This aspect so confusing man. Thanks

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

    Caleb, you gotta add the last 30 vids of this series to the C tutorial playlist. It takes maybe 5-10 minutes at most.

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

    Your explanations and videos for C Programming are incredibly helpful. Thank you for sharing this information and your organization!!!

  • @Tuan-fq9sm
    @Tuan-fq9sm 2 роки тому +1

    I really enjoy how he started talking about food at the middle of the code.

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

    could not find anyone else doing an example of this one. TY

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

    You’ve saved my life. I’ve been eating more pizza since this video and I’m now happier having had more pizza.

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

    This is amazing. Thanks for explaining in such an easy way

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

    Ok now im actually lost

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

      On what specifically? I might be able to help and explain.

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

    you definitely deserve more and more, thank you sooooooooooooo much

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

    What I learned from this video? Pizza > Tacos. Thank you for the clarification ;)

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

    Thank you so much, this tutorial is carrying me through university!

  • @mk_scar-4485
    @mk_scar-4485 5 років тому +1

    thank you man ,i am in college and this helped me a lot!

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

    nested loops are just cogs. As one turns, so does the other.

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

    pizza not better than tacos

  • @Blank-Kong2RuYe
    @Blank-Kong2RuYe Рік тому

    tqsm for the tutorial, though im curious whats the name for ur outro😅, ik its "rx savagez-wolves" but theres weird noise every few seconds + ur vid is 2 yrs older than his

  • @JuanPabloHernandezRamirez-s8e
    @JuanPabloHernandezRamirez-s8e 21 день тому

    2:35 ayo, idk if you're talking about taco bell, but mexican tacos are better than pizza, no discussions

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

    02:23 Isn't by convention the inner loop letter j? It is the next letter after i.

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

    Pizza > tacos

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

    Which software is this ?

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

    why do you print %d? what does that do?

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

      its float data type similarly to we use %s in string, we use %d or %f for double or float

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

    Thanx, u r so good at explanation

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

    pizza is not better than tacos lol

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

    I have 3 for loops that I should merge to two for loops can someone help me?

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

      If you reply to this comment with your code, I can take a look and offer some suggestions.

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

    You are the best

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

    Can you do one for c++

  • @KeyMrLock
    @KeyMrLock 4 роки тому +9

    you were in my dream last night caleb, at a waterfall

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

    I'm confused. It looks like it is only printing k, how does it know to print i too? :(

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

      Make sure you have a print in the inner loop 😊

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

      @@codebreakthrough Thank you Caleb. I have the printf in the nested loop. But I just don't get how the computer knows to print 0, 10, 210.... It has printf("%d ",k); so I assumed (making a butt of myself) that it will only print k's value. Im watching all of the videos in your C tutorial and I have to say they are awesome! Thank you so much!!!!!!

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

    Tacos over pizza!

  • @rouane.houssam
    @rouane.houssam 4 роки тому

    go ahead bro really you are amazing

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

    I know i am 2 years late but
    What do i put if i want to place number like
    1,2,3,4,5,6,7,8,9,10
    1,2,3,4,5,6,7,8,9
    1,2,3,4,5,6,7,8
    So on
    I'm a beginner at coding btw
    And i need your help

    • @josh-rs1hr
      @josh-rs1hr 2 роки тому +1

      #include
      int main()
      {
      for (int i = 10; i>0; i--)
      { printf ("
      ");
      for (int j = 1; j

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

      Did you ever get an answer to this question? I'm curious how to do that now

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

      actually I sorted it out, if anyone is curious about this question and wants the solution this is how I did it
      int main()
      {
      for (int i = 10; i >= 1; i--)
      {

      for(int k = 1; k

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

    caleb I love you but tacos >= pizza;

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

      i think tacos == pizza; XD

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

    i mean, you make a lot of unnecessary side comments but great tutorial nonetheless!

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

    Am I the only one that still doesn't get it? Lol

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

    The Best

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

    What is the name of the outtro music at 5:50?

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

      i wanna know too ;-; , it may be "wolves' from rx savagez but theres always a weird noise every few seconds

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

      @@Blank-Kong2RuYe Thank you! I think you are right. It's wolves' from rx savagez. I looked it up on youtube and it was this song. And you are also right about that noise every few seconds ....like a 'ping' that you hear on airlines when they want to make an announcement.

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

      @@okkami676 glad u found it! though I doubt rx savagez is the original author since he posted 2 yrs after this video

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

    OMGGGGG THANK YOU.... SPACE IS IMPORTANT TOO! HAHA

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

    One question..
    What if we want to count a particular number in for loop... Ex. I want to count the number of 7’s in that whole loop... how do i do that..?!?

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

      if (i == 7)
      {
      numOf7++;
      }
      if (j == 7)
      {
      numOf7++;
      }

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

    tacos

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

    I think this video main topic is how pizza is better than tacos (҂⌣̀_⌣́)

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

      i think tacos == pizza; XD

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

    I have a question
    How do I create this??
    . . . #
    . . ##
    . ###
    ####
    I tried so hard but I can't figure it out can someone help me PLEASE 😭

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

      Jojo X now i where your stidying coz this is actually home work😂😂😂😂😂😂😂😂

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

      @@kingnicky2568 it was the harvard edx cs50 course lmao and I figured it out by now btw 😍😍😍

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

      Jojo X i am a programer too mind if we connect.? I have home work and still cant figure it out... if so please text me “kingnickyjr999@gmail.com”

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

      #include
      /*
      ---#
      --##
      -###
      ####
      */
      int main()
      {
      int height;
      printf("Enter the height of the triangle : ");
      scanf("%d", &height);
      for(int i = 1; i i; j--){
      printf(" ");
      }
      for(int k = 0; k < i; k++){
      printf("#");
      }
      printf("
      ");
      }
      return 0;
      }
      like this??

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

      @@daverussell4052 lol omg thanks 😂😅🥺😍

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

    *
    ***
    *****
    *******
    *********

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

    bro when you make a video cut to the chase and stop talking about pizza and tacos

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

      bro...free videos, none of which are over 8 to 9 minutes long. If you don't want pizza or taco talk, pay for a course. If I'm not mistaken the forward arrow key skips ahead about 15 seconds or so as well.

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

    sweeeeeeeeeet