I will consider the following issues:
1) the rand() ) function is defined in stdlib , as you can read here . time refers to time(NULL) to the srand function
2) srand() - The pseudo random number generator is initialized using the argument passed as a seed.
For every other seed value used in the srand call, you can expect the pseudo random number generator to generate a different sequence of results on subsequent calls to rand.
Two different initializations with the same seed will generate the same sequence of results in subsequent calls to rand.
If the seed value is 1, the generator is reinitialized to its initial value and returns the same values ββas before any rand or srand call.
To generate random numbers, srand usually initialized with some distinctive runtime value, such as the value returned by the function time (declared in the <ctime> header). This is common enough for most of the trivial needs of randomization.
source share