224k views
0 votes
What is difference between rand() and srand() ?

1 Answer

3 votes

Answer:

rand() function generate the random number within the range.

srand() function decide the starting point for random function or set the seed for rand() function.

Step-by-step explanation:

rand() function which is used to generate the random number within the range.

srand() function is used to decide the starting point for random function.

In sort meaning, it set the seed for rand() function.

if srand() function not used, the random function generate the same output again and again because the starting point is fixed for generating the random number.

if srand() function used it change the starting point every time and random function generate the output different in every time.

User Mighty Ferengi
by
8.0k points