srand
void srand(int seed)Description
Initializes the random number generator with the given seed value.
Should be called before using rand() to ensure reproducible or varied random sequences.
Using the same seed always produces the same sequence of random numbers.
Parameter
- seed - An integer used to seed the random number generator.
Example
void main()
{
srand(42); // Seed with fixed value – reproducible sequence
srand(GetTimestamp()); // Seed with current timestamp – varied sequence
int r = rand(100); // Random number in [0, 99]
}