/* "random" is declared in stdlib.h. */ #include /* This program uses "time" to seed the random number generator. */ #include #include int main () { int i; /* This prints the same random numbers each time. */ for (i = 0; i < 5; i++) { printf ("%d:%ld\n", i, random ()); } /* To get different random numbers, use "srandom" to seed the random number generator with the current time in seconds. */ srandom (time (0)); /* This prints different random numbers each time. */ for (i = 0; i < 5; i++) { printf ("%d:%ld\n", i, random ()); } return 0; }