In many cases and particularly in computer games, a seed number cannot be provided on every event. We need some function whose return value is always changing. Time is always changing; so, we make use of function time() defined in the header file <time.h>.
The function time (Null)gives a number which is equal to the number of seconds elapsed till now since 1st January 1970 Greenwich time 00:00:00. This number is always changing. The problem of using a different number as seed number is solved by the following code:
long unsigned seed.= time(Null);
Or we may use the following code:
Program uses srand (time (Nu11)); as well as displays the value of seed number.
long unsigned seed;
printf("seed = %d\n", seed);
printf("The random numbers are as below.\n");
The expected output is as given below.