The random function

Description

The random function returns a random number. The type of the value returned by this function is either integer, or real depending on whether the optional parameter is supplied.

Parameter

The random function's optional parameter is an expression of integral type. If this parameter is supplied then the value returned by this function is a random integer between zero and the value of the parameter minus 1 (i.e. if the value of the parameter is I then the value returned by this function is a random integer between zero and I-1). If the parameter is not supplied then the value returned by this function is a random real number between zero and one.

Example

   random(10);     //returns a random integer between 0 and 9
   random;         //returns a random real number between 0 and 1

Portability

Operating Systems: All
Standard Pascal: No