C++ Programming Tutorial 46 - Working with Arrays

Поделиться
HTML-код
  • Опубликовано: 5 фев 2025
  • Start your software dev career - calcur.tech/de... 💯 FREE Courses (100+ hours) - calcur.tech/al...
    🐍 Python Course - calcur.tech/py...
    ✅ Data Structures & Algorithms - calcur.tech/ds...
    ~~~~~~~~~~~~~~~ CONNECT ~~~~~~~~~~~~~~~
    ✉️ Newsletter - calcur.tech/ne...
    📸 Instagram - / calebcurry
    🐦 Twitter - / calebcurry
    🔗 LinkedIn - / calebcurry
    ▶️ Subscribe - calcur.tech/sub...
    👨🏻‍🎓 Courses - www.codebreakt...
    ~~~~~~~~~~~~~~ SUPPORT ME ~~~~~~~~~~~~~~
    ↪ My Amazon Store - www.amazon.com...
    🅿 Patreon - calcur.tech/pat...
    🅖 GitHub Sponsors - github.com/spo...
    Ⓟ Paypal - paypal.me/calcur
    🅑 Bitcoin - 3HnF1SWTzo1dCU7RwFLhgk7SYiVfV37Pbq
    🅔 Eth - 0x350139af84b60d075a3a0379716040b63f6D3853
    📈 Buy Bitcoin - calcur.tech/cr...
    Reserve the Ruby Steel crypto rewards card and get a $25 bonus (use affiliate code "Caleb") - calcur.tech/cr...

Комментарии • 37

  • @Kin.Grows97
    @Kin.Grows97 4 года назад +7

    Is there a reason that you used sizeof() to output the elements in the array? In my for loop I just had (int i = 0; i < guesses[i]; i ++) Is there something wrong with this way and that's why you didn't mention it? With this way it outputs everything in the array without the zeros you got when the size of the array was larger than the number of elements initialized.

    • @chanelmuir9330
      @chanelmuir9330 3 года назад +2

      if the values in your array are small enough the for-loop will end early.
      Imagine an array with the values {12, 43, 23, 2, 23}
      First you have i = 0:
      i < guesses[i] evaluates to:
      0 < guesses[0]
      0 < 12
      true
      But once you get to i = 3
      i < guesses[i] evaluates to
      3 < guesses[3]
      3 < 2
      false
      The for loop ends here as the conditions aren't met and and further values will be skipped.

    • @chanelmuir9330
      @chanelmuir9330 3 года назад +2

      to get all numbers before a zero to print out you could change the condition to guesses[i] > 0;
      for (int i = 0; guesses[i] > 0; i++)
      This would work as long as you know all of your values are positive non-zero integers, although once a zero is reached, any following values are skipped.

  • @kdtallllll
    @kdtallllll 5 лет назад +17

    When you're a star they'll let you do it. You can do anything.. Grab 'em by the index. You can do anything.

  • @rasmusamundhenriksen4369
    @rasmusamundhenriksen4369 4 года назад +9

    Could you also make a video regarding c-strings using char arrays. You already have this amazing video and also on c++ strings using std::string. Im new to c++ and i think there is really a need for a actual video with char arrays and c-strings and how they differ from c++ strings and it would also show a different usage of arrays :-) . Thanks for all of your videos

    • @liampapavasiliou9658
      @liampapavasiliou9658 3 года назад +1

      I would guess that there is something like this in his c tutorials

  • @mhero9255
    @mhero9255 4 года назад +10

    Also. Thank you, you are helping me pass college...hopefully

    • @PunmasterSTP
      @PunmasterSTP 3 года назад +1

      How’s it going?

    • @mhero9255
      @mhero9255 3 года назад +2

      @@PunmasterSTP not bad. Failed programing tho

    • @PunmasterSTP
      @PunmasterSTP 3 года назад +1

      @@mhero9255 I’m glad college is going alright, and I’m sorry to hear about programming. I never did much with coding myself; pretty much just playing around and tutoring. Java was the first thing I used back in high school, so that’s probably what I’m most comfortable with.

    • @mhero9255
      @mhero9255 3 года назад +1

      @@PunmasterSTP thanks. But it's fine. And I would like to learn java. I was started off with C++ for some reason

    • @PunmasterSTP
      @PunmasterSTP 3 года назад +1

      @@mhero9255 I took AP comp sci in my senior year in high school and that’s where I started with Java. I heard that that was the first year it used Java; before that it was C++.
      A few weeks ago, I came across coding and computing playlists made by a professor, including this one on Java ( ruclips.net/p/PLlr7Jt5dPiv6uNsAHqOpcCZq8qJF6_rA8 ). I’m also planning to check out the rest of Caleb’s playlist when I finish this one and then have the time to do it.

  • @jeezygarceezy
    @jeezygarceezy 4 года назад +2

    So what about user defined sizes?
    Enter n;
    Arr[n];
    Int I = 0; I < n... You get the idea. I'm going through the Gaddis book and I'm on chapter 6 right now and seem to be having no problem not having the size set before compile. Is that something my IDE is fixing without me knowing?

  • @omarramadan5261
    @omarramadan5261 2 месяца назад

    How come in the for loop the index of the array represented as i, despite having already incremented to the value 1, still shows the integer at index value 0?

  • @bahrant3
    @bahrant3 2 года назад +1

    does the comma not have any value in the array

  • @jalalshah185
    @jalalshah185 4 года назад +1

    why system("cls") is not working in xcode

  • @cynthialucien1926
    @cynthialucien1926 9 месяцев назад

    5:00 why is the output 413 when you're outputting guesses [0]?

    • @messsymessiah4170
      @messsymessiah4170 9 месяцев назад

      I know I'm a few days late but here goes.
      Originally he assigns guesses[0] to be 10;
      Then he overrides that to be a number that the user inserted using cin. Since he entered 413 guesses[0] became 413.

  • @quickfoods_qf
    @quickfoods_qf 5 лет назад +3

    Well explained

  • @speedspeed121
    @speedspeed121 4 года назад +6

    Hello, this was a helpful video.
    I'm an astrophysics major. I am familiar with Python but I need help with C++.
    I need help reading and plotting data from star and galaxy files. Ex. I may have a file with hundreds of stars and 3 columns; say distance, B-mag and temp.
    How can I read the file then plot it? Do I need Gnuplot and can I plot it in my code? I use Visual Studio

  • @PunmasterSTP
    @PunmasterSTP 3 года назад

    Q: What’s the size of Embarcadero’s user base?
    A: Over three million.

  • @kenkaneki3687
    @kenkaneki3687 2 года назад

    does anyone know the theme he's using?

  • @muneebrehman2499
    @muneebrehman2499 4 года назад +1

    Grt job

  • @ahmadalkhaled9204
    @ahmadalkhaled9204 3 года назад

    whats this editor?

  • @Hytension
    @Hytension Год назад +4

    This is really killing C++ for me right now

  • @mhero9255
    @mhero9255 4 года назад

    PC MASTER RACE. Build a pc