Well actually, you can get a pseudorandom number algorithmically by multiplying a seed with a constant and taking the mod of another constant. I'll show you one:
Code:
int seed=1;
void LCGseed (unsigned int _seed)
{
int i, h=1;
unsigned char *p=&_seed;
for (i=0; i < sizeof _seed; h++) {
h = h>>24 * h<<4 ^ p[i];
}
seed=h;
}
int LCGrand (void)
{
return seed*=16807UL % 2147483647UL;
}
The algorithm, when called several times, naturally produces a series called a period. Large periods are good, but more important is the factor of unpredictability. We shouldn't rely on the default seed because that would make the generator more predictable and the result very deterministic. The seed is actually the last number the generator returned. If you're using the generator for the first time, it would be a good idea to set the seed somewhere in the period to start off from other than the default value, using a unique source, like the time.
The example is actually a great deal similar to the rand/srand generator provided by C++, and that's not a very good one. But it's a place to start. You can learn more about PRNGs on the web.