Nice Question,
There are so many ways/algorithm for generating Random number, Each has its own Advantages and Disadvantages.
Coming on to the rand()
function in c,
I found definition of it from This Link
As Per stdlib.c,
static long holdrand = 1L;
...
int rand() {
return (((holdrand = holdrand * 214013L + 2531011L) >> 16) & 0x7fff);
}
Of couse this may vary from disto to distro and version to version. You should find your local stdlib.c file (or the one that corresponds to your distro) to see how exactly it's implemented.
srand() merely changes holdrand:
void srand(unsigned int seed) {
holdrand = (long) seed;
}
I Hope This Helps You,