Read more about parameters of rand in parameters section
The randfunction in C language Generates a pseudo-random number.
The rand function returns a pseudo-random integer in the range 0 to RAND_MAX inclusive (i.e., the mathematical range [0, RAND_MAX]). RAND_MAX is guaranteed to be at least 32767. The rand function uses a deterministic algorithm to generate numbers, which means that the sequence of numbers will be the same each time the program is run unless the random number generator is seeded differently using srand().
The randfunction takes 1
parameter:
•
void `none`: Indicates that the function takes no arguments.
Generates a pseudo-random number in the range [0, `RAND_MAX`]. The value of `RAND_MAX` is implementation-defined but is guaranteed to be at least 32767. The function is not suitable for cryptographic purposes. To ensure reproducibility, use `srand` to set the seed.
The rand function return value :
Returns a pseudo-random integer between 0 and RAND_MAX, inclusive
Output
This example demonstrates basic usage of rand(). It first seeds the random number generator using the current time, then generates and prints five random numbers.