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

  Рет қаралды 26,730

Professor Hank Stalica

Professor Hank Stalica

Күн бұрын

Пікірлер: 45
@Leonidnrv
@Leonidnrv Күн бұрын
Having a hard time to understand srand and why we need to change the seed. Now it's clear. Thank you!
@leythecg
@leythecg Жыл бұрын
Once again brought to the point without much fuss! Thank you very much! 👍👍👍
@ProfessorHankStalica
@ProfessorHankStalica Жыл бұрын
Glad it was helpful!
@abel1340
@abel1340 8 ай бұрын
@@ProfessorHankStalica thank you professor!on point! like the hat!
@officialdanieldsouza
@officialdanieldsouza 4 ай бұрын
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!!
@ProfessorHankStalica
@ProfessorHankStalica 3 ай бұрын
Glad it was helpful!
@duttybwoy556
@duttybwoy556 5 ай бұрын
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
@pelecaj7067
@pelecaj7067 10 ай бұрын
short and to the point. thanks
@HarisAbdullah-p6t
@HarisAbdullah-p6t Ай бұрын
Sir, Thank you so much. It helped a lot. Lots of love and thanks from Pakistan.
@safa-uc1mk
@safa-uc1mk Жыл бұрын
Thank you mister! That was a really crisp explanation 🙌
@ProfessorHankStalica
@ProfessorHankStalica Жыл бұрын
Glad you liked it!!
@EbyHamady-ul7rc
@EbyHamady-ul7rc 10 ай бұрын
It was a really excellent and calm explanation, thank you
@ProfessorHankStalica
@ProfessorHankStalica 10 ай бұрын
You're very welcome!
@ExamYou-q3i
@ExamYou-q3i Ай бұрын
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 Ай бұрын
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.
@carljohncafe6921
@carljohncafe6921 7 ай бұрын
Thank you so much! This video is a life saver.
@lydianne8013
@lydianne8013 Жыл бұрын
Thank u so much i have an exam tomorrow and i don't understand this function . U save me ❤❤
@ProfessorHankStalica
@ProfessorHankStalica Жыл бұрын
Good luck!
@ZorikaSakamishi
@ZorikaSakamishi 4 ай бұрын
Thanks sir i appreciate your work
@ProfessorHankStalica
@ProfessorHankStalica 3 ай бұрын
Thanks and welcome
@sianwa11
@sianwa11 6 ай бұрын
Thanks for the clear explanation
@ProfessorHankStalica
@ProfessorHankStalica 6 ай бұрын
Happy to help
@andrewbooher1709
@andrewbooher1709 9 ай бұрын
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?
@brigadut
@brigadut 4 күн бұрын
int x = time(NULL); srand(x); int range = 100; int randomNumber = (rand() + 1) % range; std::cout
@luisochoa5282
@luisochoa5282 12 күн бұрын
My guy is saving lives without knowing it
@23Devvrat
@23Devvrat 7 ай бұрын
great video man ! cheers
@jchdbtcmdddhuryy6332
@jchdbtcmdddhuryy6332 5 ай бұрын
Thank so much ❤
@ProfessorHankStalica
@ProfessorHankStalica 5 ай бұрын
You're welcome 😊
@Wagonik
@Wagonik Жыл бұрын
thx! very useful
@ProfessorHankStalica
@ProfessorHankStalica Жыл бұрын
Glad it helped!
@omarmohammed9938
@omarmohammed9938 9 ай бұрын
So if I wanted to generate random number from 0 to 12 Then i do this right? Cout
@ProfessorHankStalica
@ProfessorHankStalica 9 ай бұрын
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.
@yooniecardbtsclips
@yooniecardbtsclips 11 ай бұрын
Thankssss
@ProfessorHankStalica
@ProfessorHankStalica 11 ай бұрын
You are welcome.
@youssefkawtharani2536
@youssefkawtharani2536 Жыл бұрын
What if i want the user to enter a random number and the program should tell true or false?
@ProfessorHankStalica
@ProfessorHankStalica Жыл бұрын
if(userEnteredNumber == randomNumberGenerated) cout
@hosseinbachari6732
@hosseinbachari6732 2 ай бұрын
Thanks , your voice is a little low
@ProfessorHankStalica
@ProfessorHankStalica Ай бұрын
I'll work on that in future videos. Thanks.
@volkwell-wk3eq
@volkwell-wk3eq 8 ай бұрын
"cstidlib" I laughed
@M7medKasem
@M7medKasem 11 ай бұрын
You look charismatic, however can pull off the goofiest face in the party at anytime.
@ProfessorHankStalica
@ProfessorHankStalica 11 ай бұрын
Now, if only the ladies thought so, I'd be in business... 👍🤣😂
@M7medKasem
@M7medKasem 11 ай бұрын
@@ProfessorHankStalica you're the cool professor in college for sure 🫶🫶😂
@ProfessorHankStalica
@ProfessorHankStalica 11 ай бұрын
@@M7medKasem Well, far be it from me to argue with someone with such obvious intelligence!
@Aarpod
@Aarpod 9 ай бұрын
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
Programming Is Cooked
9:30
ThePrimeTime
Рет қаралды 279 М.
Миллионер | 3 - серия
36:09
Million Show
Рет қаралды 2,1 МЛН
How to Fight a Gross Man 😡
00:19
Alan Chikin Chow
Рет қаралды 17 МЛН
20 JavaScript One-Liner Functions You Need to Know
9:57
Coding With ArsenTech
Рет қаралды 38
True Random Numbers - Computerphile
12:16
Computerphile
Рет қаралды 129 М.
5 Signs of an Inexperienced Self-Taught Developer (and how to fix)
8:40
you will never ask about pointers again after watching this video
8:03
C++ random numbers (#17) 🎲
10:59
Bro Code
Рет қаралды 12 М.
My 10 “Clean” Code Principles (Start These Now)
15:12
Conner Ardman
Рет қаралды 287 М.
why do void* pointers even exist?
8:17
Low Level
Рет қаралды 388 М.
Миллионер | 3 - серия
36:09
Million Show
Рет қаралды 2,1 МЛН