The `rand()` function returns a random number *x*, between 0 and 1, such that *0 <= x <1*. The value returned by the random function could be zero but it is never returned as zero. In AWK, `rand()` starts generating numbers from the same starting number (also known as the seed) on each run. The algorithm used to generate the random numbers is fixed, so the numbers are repeatable. Numbers are random within one AWK run, but they are predictable from run to run. To generate different numbers in each run, you must change the seed value for each run. This is generally done using `srand()`. The following code block shows an example of a `rand(expr)` function:

$ vi rand1.awkBEGIN { print "Random num1 = ", rand() print "Random num2 = ", rand() ...