rand() is a pseudo random number generator. It isn't really random, just appears to be. It depends on the initial value seeded to the algorithm. If this value is 12, rand() will always give you the same sequence. Run this program multiple times to see:
Code:
#include <stdio.h>
#include <stdlib.h>

int main( void )
{
  int i;

  srand( 12 );
  for ( i = 0; i < 10; i++ )
    printf( "%d ", rand() );
  putchar( '\n' );
}
Code:
$ cat test.c
#include <stdio.h>
#include <stdlib.h>

int main( void )
{
  int i;

  srand( 12 );
  for ( i = 0; i < 10; i++ )
    printf( "%d ", rand() );
  putchar( '\n' );
}
$ cc -o test test.c
$ ./test
1687063760 945274514 247215794 1768547008 1478315323 279012855 668221829 1109214873 1378701697 1054489464 
$ ./test
1687063760 945274514 247215794 1768547008 1478315323 279012855 668221829 1109214873 1378701697 1054489464 
$ ./test
1687063760 945274514 247215794 1768547008 1478315323 279012855 668221829 1109214873 1378701697 1054489464