rand() and srand() | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

rand() and srand()

Actually, I can't differentiate b/w rand() and srand() function, Anyone who can guide me?

22nd Aug 2018, 12:32 PM
Faraz Shaikh
1 Answer
+ 1
When u use srand() you are defining the seed that will be used to create a random number. Just notice that those number aren't really random, because they are obtained from an algorithm that uses a seed to generate them. If this seed is changed, the random component will be higher.
22nd Aug 2018, 12:42 PM
Jose Antonio
Jose Antonio - avatar