Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3
I'm not sure where you saw random 'members', but using the rand function is popular in a situation where you want the outcome of something to be unknown at runtime. Games are a great example for this. Say you want a power-up to appear, but you want its location to be random; this is why the rand function is used. As a side note, computers are said to be incapable of total "randomness" and are instead said to only output pseudo-random results. Regardless, using time as the random seed is as close as you can get to total randomness and is actually close enough to be able to tell the difference. I hope this is what you were asking. Once again, I'm not sure what you mean by random 'members'. EDIT: Okay, I saw that you were asking about random 'number' haha. I think my explanation covers that question still. rand will always return an integer number according to its seed, set by using the 'srand()' function.
14th Mar 2017, 6:06 PM
Zeke Williams
Zeke Williams - avatar