srand() sets the start point for generating random numbers.
rand() generates a random number.
time() gets the system time.
The reason srand() is called using time() as the [araemter a lot is to produce a new number on each call so that the numbers remain random each time the program is run.
Syntax
time_t time( time_t *timer );
Code:
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main(void)
{
int i;
/* Seed the random-number generator with current time so that
* the numbers will be different every time we run.
*/
srand( (unsigned)time( NULL ) );
/* Display 10 numbers. */
for( i = 0; i < 10;i++ )
printf( " %6d\n", rand() );
}