Generating random numbers

Generating Random Numbers :

  • random() and randomize() are two macros of stdlib.h that can be used for generating random numbers.
  • random(n) generates numbers within the range 0 to n-1.
  • To generate the numbers within  a specified range (L to U) using random() , we need to change the use of random() to
    random(U-L+1)+L
  • randomize() initializes the random number  generator with a random number.

C SOURCE CODE :

 

Leave a Reply

Your email address will not be published. Required fields are marked *