#include #include #include #include int main(void) { int i; time_t tick; printf("rand() function examples\n"); printf("no seed: "); for(i = 0; i < 5; i++) printf("%10d ", rand()); putchar('\n'); (void) srand(1); printf("seed 1: "); for(i = 0; i < 5; i++) printf("%10d ", rand()); putchar('\n'); sleep(1); tick = time(NULL); printf("seed %ld: ", tick); (void) srand((unsigned int) tick); for(i = 0; i < 5; i++) printf("%10d ", rand()); putchar('\n'); sleep(1); tick = time(NULL); printf("seed %ld: ", tick); (void) srandom((unsigned int) tick); for(i = 0; i < 5; i++) printf("%10ld ", random()); putchar('\n'); return(0); }