Difficulty: Easy
Correct Answer: returns a random number generator with a random value based on time.
Explanation:
Introduction / Context:
This question refers to Borland/Turbo C for DOS, which provides non-standard functions such as randomize() and random(). Understanding legacy behavior is useful when reading old codebases or porting programs.
Given Data / Assumptions:
randomize() is available along with random() or rand().
Concept / Approach:
In Turbo C, randomize() initializes (seeds) the pseudo-random number generator using a semi-random value, commonly derived from the system clock. It does not return a random number; rather, it prepares subsequent calls to random()/rand() to yield different sequences between runs.
Step-by-Step Solution:
Verification / Alternative check:
Without randomize(), consecutive runs produce the same sequence (deterministic seed). With it, the seed changes and so do the outputs.
Why Other Options Are Wrong:
returns a random number: That describes random() or rand(), not randomize().
returns a random number generator in the specified range: Confuses generation with seeding and range restriction.
return a random number with a given seed value: Seed is set, not returned; and randomize() does not take an explicit seed.
Common Pitfalls:
randomize() to produce a number directly.
Final Answer:
returns a random number generator with a random value based on time.
Discussion & Comments