Find the max or min value in an array (C++ programming tutorial)

Поделиться
HTML-код
  • Опубликовано: 25 янв 2025

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

  • @toxicwall6593
    @toxicwall6593 2 года назад +2

    Let it be known, for i am currently a freshman in IT and I shall come back when I've graduated (hopefully) to thank you once again for the aid you've given me. This tutorial shall be one of the many steps I'll use to attain greatness, so for now, thank you.

  • @Julia-oq2nd
    @Julia-oq2nd 5 лет назад +17

    THANK YOU!!! YOU SAVED ME FOR MY ASSIGNMENT DUE TONIGHT LOL

  • @muhammadan-nasdzikrullahbi9769
    @muhammadan-nasdzikrullahbi9769 4 года назад +7

    THANK YOUU !! back when I'm in semester 1 learning statics you saved me by teaching trusses analysis and now you saved me again by teaching c++ , you really are the best, thank you =) really appreciate it !!

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

      Amazing!!! Glad I can keep helping you out my friend =) =)

  • @SmartProgramming
    @SmartProgramming 6 лет назад +10

    concept was very nicely explained, thank you, keep it up 👍👍🙂🙂

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

    Honestly your approach here made my life easier.Thanks a lot.

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

      Amazing. Really glad to hear it! You might wanna check out all the other C++ videos that I did here: engineer4free.com/cplusplus 😊

  • @lickguitars1276
    @lickguitars1276 11 месяцев назад +1

    you hav e saved me from my confusion thank you

    • @Engineer4Free
      @Engineer4Free  11 месяцев назад +1

      Glad to help!! Full C++ playlist is down in the description! 😁

  • @Rawoonah2cool
    @Rawoonah2cool 7 лет назад +1

    Thank you sooo much, I always asked why we initialized the max or min to the first element of the array and when I asked someone there answer is always to find the max, but now I finally know thanks

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

    Cobol equivalent code:
    Working-storage section.
    01 save-num pic 9(2) value 0.
    01 W-num-TABLE.
    04 W-num OCCURS 5 TIMES
    INDEXED BY W-num-NDX.
    10 num-array PIC 9(2).
    88 num1 VALUE 02.
    88 num2 VALUE 04.
    88 num3 VALUE 08.
    88 num4 VALUE 01.
    88 num5 VALUE 06.
    procedure division.
    perform varying w-num from 1 by 1 until w-num-ndx > 5
    if num-array (w-num-ndx) > save-num
    move num-array (w-num-ndx) to save-num.
    display 'max number ' save-num.

  • @shat104
    @shat104 5 лет назад +1

    this was such a smart approach, how did i no think about this.

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

    i was searching a totally different tutorial, but some tutorial of basic things is good

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

      Glad you liked it! Many more similar tutorials here: engineer4free.com/cplusplus =)

  • @Darkknight9035
    @Darkknight9035 3 года назад +3

    how do i show both max and min at the same time?

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

    YOU ARE BRILLIANT AND I LOVE YOU SO MUCH AND THANK YOU FOR EXISTING

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

      THANKS HANA. I’M GLAD YOU EXIST TOO ✨

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

      Engineer4Free THANK YOU SO MUCH AND STAY AWESOME 🥺

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

    Wow! This is very straight forward. Thanks so much.

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

      You're welcome! Full playlist is at engineer4free.com/cplusplus 🙂

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

    @Engineer4Free , what is the name of the IDE you are using ?

  • @isaacfrench5508
    @isaacfrench5508 6 лет назад +8

    How do you do you get the max and min of an array where the user inputs all the values?

    • @mehrosenasir3966
      @mehrosenasir3966 5 лет назад +1

      the same code will apply bro, just assume the first value at 0 index is largest among all then run a loop till the array length with a if condition.

    • @shat104
      @shat104 5 лет назад +1

      i'm assuming you figured it out but i was able to put something together. if you find a better way please reply
      int max {0};
      int arr[5];
      for(size_t i{0}; i < 5; i++){
      coutarr[i];
      }
      cout

    • @Engineer4Free
      @Engineer4Free  5 лет назад +1

      Yeah thanks for this. I didn't try running it but the concept looks right. Use a loop to have the user input to the array then use another loop after to do the check 🙂

    • @reactionseeker3
      @reactionseeker3 5 лет назад

      The array has to always be a set number. The user can go below but not above that set number so you would use this example in exactly the same way. The only change would be to the five when you initialize the array. The five would change to however big you want your array to be.

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

    I'm currently learning C but this helped too, thanks.

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

    hello do you have a tutorial about swapping???

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

      Unfortunately no. But you can check out all the videos that I made here: engineer4free.com/cplusplus

  • @Abdulaziz-cl8uw
    @Abdulaziz-cl8uw Год назад +1

    Thank you man !! helped me a lot

  • @DarkGT
    @DarkGT 8 лет назад

    No one book of Debugger can learn to understated the code as read human being explain it step by step. Thanks.

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

    what compilator are u using? its very helpful for begginers

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

      The IDE that you see in this video is called XCode

  • @aaaliii4u
    @aaaliii4u 8 лет назад +4

    i'm a developer my self and that is a good job.. (Y)

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

    Thank you!!! This really helps and it works well!

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

    Would this be an example of a linear search algorithm?

  • @AminaZalewska
    @AminaZalewska 6 лет назад +2

    best explanation ever

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

    what IDE program do you use?

  • @ZakirImadullah-lm3vc
    @ZakirImadullah-lm3vc 2 года назад

    Simple smart and intellect, thanks for sharing this with us!

  • @joeljb25
    @joeljb25 5 лет назад +1

    Thank you thank you, dumbed it down for a newb.

  • @chaos.1013
    @chaos.1013 3 года назад

    How about when using classes and objects ?🤔

  • @syedabdullahmugheeszaidi8638
    @syedabdullahmugheeszaidi8638 5 лет назад +1

    What compiler are you using?

    • @Engineer4Free
      @Engineer4Free  5 лет назад

      I used Xcode as my IDE in these videos

  • @roshanes225
    @roshanes225 5 лет назад

    Simple and perfect explanation

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

    how to output both min and max in one console?

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

      Mmmm did you not notice though that I changed the variable name and multiple other lines. The code that finds and outputs the max is different than the code that finds and outputs the min.

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

    It was so simple, meanwhile I was trying to compare every element in the array. Feels like I'm dumb xD

  • @peterakoh3432
    @peterakoh3432 7 лет назад +1

    Thanks GOD bless you for using it to solve an exam question for me.

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

    would this method work with a 2D array that was filled with a file? Of course adding and changing a few things

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

      Yeah it should. See video 40 here: engineer4free.com/cplusplus and also consider using vectors of vectors if you're allowed to (which are the topic of videos 41 - 47)

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

      @@Engineer4Free thank you, if only I was allowed to use vectors 😂, I wouldn't be 50+ hours into this homework.

  • @مرتضىصبري-ب4ج
    @مرتضىصبري-ب4ج 7 лет назад +4

    thank you the video was very clear

    • @Engineer4Free
      @Engineer4Free  7 лет назад

      Glad to hear it, thanks for commenting!

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

    Quick question what application are you using to code? it looks neat

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

      Xcode. You can see all the hardware and software that I use here: engineer4free.com/tools ✌️

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

      Ooo ok thank you!

  • @dndnegy73
    @dndnegy73 6 лет назад +1

    Very simple and clear
    Thanks

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

    Thank you! Very helpful.

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

    can you help how to find a local min?

  • @afetsoykok267
    @afetsoykok267 6 лет назад +1

    your explanation is perfect! thanks a lot

    • @Engineer4Free
      @Engineer4Free  6 лет назад

      Awesome! Thanks for letting me know =)

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

    My teacher wants the one without arrays... How do I do that?

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

    std::cout

  • @bradleychampagne9103
    @bradleychampagne9103 5 лет назад

    awesome! now...how to identify which element is the max, meaning the output would say something to the effect of, "it is the third element," or output 3 in this case since 8 is the largest element and it is the 3rd element. thank you

  • @tonyfantom3142
    @tonyfantom3142 5 лет назад

    does this work with c as well?

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

    how to find 2nd largest num?

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

    How could we show that max or min number is at which location of array.....

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

      Yes you could definitely do it with another variable or two

  • @harmankaur437
    @harmankaur437 6 лет назад

    Thanks for video..could u plz tell me how can i write elements between max and min in an another array? Thanks again!!

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

    Thank you soooo mich.
    Explained very well.

  • @thewiedzmin6062
    @thewiedzmin6062 6 лет назад

    What if I don't know what the user will input?
    Should I create an integer to compare all the inputs to that?!(I am pretty sure it's not gonna work though!)

    • @Engineer4Free
      @Engineer4Free  6 лет назад

      Mmmm this operation can still work after the user has inputed, as the values will be set then, just not before.

  • @mikeahmed7092
    @mikeahmed7092 8 лет назад

    Excellent Explanation!

  • @anasshakil
    @anasshakil 8 лет назад +2

    which IDE you're using ?

    • @Engineer4Free
      @Engineer4Free  8 лет назад +1

      Hey Anas I use Xcode, there is a link to download it at engineer4free.com/tools Thanks for watching!

    • @anasshakil
      @anasshakil 8 лет назад

      Engineer4Free Thanks :)

  • @kobeel666
    @kobeel666 6 лет назад +1

    easy to understand thanks!

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

    Thanks a lot sir keep going

  • @catherinefam6580
    @catherinefam6580 6 лет назад

    Can we find both of the max and min value in the same program?

  • @abdullahabualkhair7516
    @abdullahabualkhair7516 5 лет назад

    what I do if he required max value located at diagonal in 2-D array?

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

    THANK YOU SOOOOO MUCH MAN!!!! :-)

  • @blind_neighbourhoodNerd
    @blind_neighbourhoodNerd 6 лет назад +1

    thanks so much for this

    • @Engineer4Free
      @Engineer4Free  6 лет назад

      Hey you're welcome, glad you found it useful! I did a whole playlist on C++ that you might like, you can check it out at engineer4free.com/cplusplus

    • @blind_neighbourhoodNerd
      @blind_neighbourhoodNerd 6 лет назад

      @@Engineer4Free thankyou!! I will check those out. I don't suppose you know how I would display the element position of a max or min value in a 2d array? sorry if its a really silly question but I've been stuck on this for ages.
      Thanks heaps!!

  • @RoyAndrews82
    @RoyAndrews82 6 лет назад

    This will just spit out the maximum value it doesn't necessarily tell you which sensor that gave you the data (max value).

  • @catherinefam6580
    @catherinefam6580 6 лет назад

    This program run only looking for the min value in an array. How about the max value?

    • @Engineer4Free
      @Engineer4Free  6 лет назад

      At 4:48 this program prints the max value of the array to the screen.

    • @catherinefam6580
      @catherinefam6580 6 лет назад +1

      oh yeah, this program is quite nice.

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

    Good job

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

    life saver! Thank you for using plain english xD

  • @ibrahimtamemy8828
    @ibrahimtamemy8828 8 лет назад +1

    thanks excellent tutorial

    • @Engineer4Free
      @Engineer4Free  8 лет назад +1

      Thanks for commenting, glad you found it helpful!

  • @7esohaib927
    @7esohaib927 5 лет назад

    for loop will run only 4 times
    it should run 5 times
    so i should be smaller than 6
    :)

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

      You are right. Check my Cobol equivalent code above.

  • @aukselevonaite7572
    @aukselevonaite7572 9 лет назад

    that's great! i like this lesson :) you helped me very good today :)

    • @Engineer4Free
      @Engineer4Free  9 лет назад

      +auksė levonaitė Glad to hear it! You can find the rest of the C++ tutorials I made here: www.engineer4free.com/cplusplus :)

  • @kristiyanivanov9509
    @kristiyanivanov9509 6 лет назад +2

    Helpful af

  • @informativecontent4778
    @informativecontent4778 6 лет назад

    which compiler is this??

    • @Engineer4Free
      @Engineer4Free  6 лет назад +1

      I used Xcode as my IDE. Full list of my hardware and software is here: engineer4free.com/tools

    • @informativecontent4778
      @informativecontent4778 6 лет назад

      thanks for replying but why isn't is compatible with windows

    • @Engineer4Free
      @Engineer4Free  6 лет назад

      It's a Mac product. Here's a pretty good list of many different options that are out there www.stroustrup.com/compilers.html

  • @kompashka95
    @kompashka95 7 лет назад

    Этот мужик настолько хорош, что я не слова не понимая по английски, во всем разобрался благодаря ему.

    • @Engineer4Free
      @Engineer4Free  7 лет назад

      Я рад, что видео помогает. Спасибо за просмотр! Я вообще не говорю по-русски, мне пришлось использовать перевод Google :p
      I'm glad that the video helps. Thanks for watching! I don't speak any Russian, I had to use Google Translate: p

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

    write a c++ program to sort a numeric array and string array
    Plz provide ans of this🙏🙏🙏🙏

  • @sasa_official23
    @sasa_official23 7 лет назад +1

    Thanks a lot brother...

  • @makarasan4828
    @makarasan4828 7 лет назад

    can window use IDE Xcode?

    • @Engineer4Free
      @Engineer4Free  7 лет назад

      Xcode is only for Mac, but there are many windows alternatives: alternativeto.net/software/xcode/?platform=windows

  • @hatedbylifeitself6730
    @hatedbylifeitself6730 6 лет назад +1

    THANK YOU A LOT

  • @techtrovehq
    @techtrovehq 6 лет назад +1

    Thanks bro.

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

    THANK YOU!! :')

  • @ShuyanStoryTeller
    @ShuyanStoryTeller 8 лет назад

    Thank you so much sir.

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

    finaly get it

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

    Idle name please

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

      Xcode. All the hardware and software that I use can be found at engineer4free.com/tools 👍👍

  • @lmnop291
    @lmnop291 7 лет назад

    next tie jus put the code in the description thx

    • @Engineer4Free
      @Engineer4Free  7 лет назад

      Annoying as it is, I think its good practice to type these short examples out from scratch. Thanks for watching!

  • @abdelghaderabbe5257
    @abdelghaderabbe5257 8 лет назад

    thank you sooo much

  • @90smanoofficial79
    @90smanoofficial79 5 лет назад +1

    This is not working in visual studio studio

  • @jianhaowang220
    @jianhaowang220 6 лет назад

    that is amazing

  • @AL-wc8oy
    @AL-wc8oy 3 года назад +1

    Nicccccccceeee

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

    Sunder Pichai?? 🤔😄

  • @raheemamer9261
    @raheemamer9261 6 лет назад

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

    Thanks a lot!

  • @naumankhan3645
    @naumankhan3645 5 лет назад

    Thanks Bro

  • @bob27111
    @bob27111 6 лет назад +1

    thanx a lot!