Generating Random Numbers in C++: Exploring rand(), srand(), and time() Functions [Tutorial] [8]

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

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

  • @Leonidnrv
    @Leonidnrv Месяц назад +1

    Having a hard time to understand srand and why we need to change the seed. Now it's clear. Thank you!

  • @leythecg
    @leythecg Год назад +9

    Once again brought to the point without much fuss! Thank you very much! 👍👍👍

    • @ProfessorHankStalica
      @ProfessorHankStalica  Год назад +2

      Glad it was helpful!

    • @abel1340
      @abel1340 10 месяцев назад

      @@ProfessorHankStalica thank you professor!on point! like the hat!

  • @pelecaj7067
    @pelecaj7067 11 месяцев назад +5

    short and to the point. thanks

  • @safa-uc1mk
    @safa-uc1mk Год назад +5

    Thank you mister! That was a really crisp explanation 🙌

  • @EbyHamady-ul7rc
    @EbyHamady-ul7rc Год назад +3

    It was a really excellent and calm explanation, thank you

  • @officialdanieldsouza
    @officialdanieldsouza 5 месяцев назад +1

    Excellent tutorial! I tried to understand the same concept through reading some blog articles online but didn't fully grasp the concepts that you discussed in clear, simple level of understanding in this video.
    Thanks again!!

  • @duttybwoy556
    @duttybwoy556 6 месяцев назад +1

    Very good , clear and simple explanation !!! good job...
    I also saw this line srand(time(NULL)); on top of the main function for this to not generate the same number all the time

  • @carljohncafe6921
    @carljohncafe6921 9 месяцев назад +1

    Thank you so much! This video is a life saver.

  • @HarisAbdullah-p6t
    @HarisAbdullah-p6t 3 месяца назад

    Sir, Thank you so much.
    It helped a lot.
    Lots of love and thanks from Pakistan.

  • @ZorikaSakamishi
    @ZorikaSakamishi 5 месяцев назад +1

    Thanks sir i appreciate your work

  • @sianwa11
    @sianwa11 8 месяцев назад

    Thanks for the clear explanation

  • @ExamYou-q3i
    @ExamYou-q3i 3 месяца назад

    wow !!!! like i couldnt even understand it from chat gpt!!!!! but you made it look so easy like a sittng duck. thank you sooo much

    • @ProfessorHankStalica
      @ProfessorHankStalica  3 месяца назад

      The funny thing about ChatGPT is that it's wrong. A lot. Don't depend on it for school work. 1. It's cheating. 2. You won't learn anything. 3. It's wrong a lot.

  • @jchdbtcmdddhuryy6332
    @jchdbtcmdddhuryy6332 7 месяцев назад

    Thank so much ❤

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

    How would you go about reading a user input in the range of numbers? For example, if you wanted them to pick a number 1 - 10. How could you make it so it reads if they picked within that range?

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

    great video man ! cheers

  • @lydianne8013
    @lydianne8013 Год назад +1

    Thank u so much i have an exam tomorrow and i don't understand this function . U save me ❤❤

  • @Wagonik
    @Wagonik Год назад

    thx! very useful

  • @Knochentod
    @Knochentod Месяц назад

    Is it possible to save the numbers and then calculate with them or something?

    • @ProfessorHankStalica
      @ProfessorHankStalica  27 дней назад

      Sure. Place them in a variable and then use the number for whatever you need it for.

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

    My guy is saving lives without knowing it

  • @juanyeclay
    @juanyeclay Месяц назад

    damn good video bro

  • @yooniecardbtsclips
    @yooniecardbtsclips Год назад

    Thankssss

  • @youssefkawtharani2536
    @youssefkawtharani2536 Год назад

    What if i want the user to enter a random number and the program should tell true or false?

  • @omarmohammed9938
    @omarmohammed9938 11 месяцев назад

    So if I wanted to generate random number from 0 to 12
    Then i do this right?
    Cout

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

      Close. rand() % 13 because of how modulus works. If you divide any number by 13 by, the remainder will be any integer from 0 - 12.

  • @hosseinbachari6732
    @hosseinbachari6732 4 месяца назад +1

    Thanks , your voice is a little low

  • @volkwell-wk3eq
    @volkwell-wk3eq 10 месяцев назад

    "cstidlib"
    I laughed

  • @brigadut
    @brigadut Месяц назад

    int x = time(NULL);
    srand(x);
    int range = 100;
    int randomNumber = (rand() + 1) % range;
    std::cout

  • @Aarpod
    @Aarpod 11 месяцев назад

    You shoulda wrote the textbook im using for class right now. I don’t know how the author is gonna just drop rand/srand in an example program without context and be like:
    “Edit the program so it displays 1-10”
    Like nah thats not how it works chief

  • @M7medKasem
    @M7medKasem Год назад +1

    You look charismatic, however can pull off the goofiest face in the party at anytime.

    • @ProfessorHankStalica
      @ProfessorHankStalica  Год назад +1

      Now, if only the ladies thought so, I'd be in business... 👍🤣😂

    • @M7medKasem
      @M7medKasem Год назад

      @@ProfessorHankStalica you're the cool professor in college for sure 🫶🫶😂

    • @ProfessorHankStalica
      @ProfessorHankStalica  Год назад +2

      @@M7medKasem Well, far be it from me to argue with someone with such obvious intelligence!