Can someone verify if my understanding is correct?
I have read some document that says:
rand() function computes a sequence of pseudo-random integers in the range 0 to RAND_MAX. Returns a pseudo-random integer.
srand(seed) : uses the argument for a new sequence of pseudo-random numbers to be returned by subsequent calls to rand.
Questions:
1. How many numbers are generated when srand is seeded. For example, in the following code, it seems as if srand() has generated a huge list of numbers and rand() returns a number based on some formula. Is this right?
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
srand(1);
printf("%d\n", rand());
printf("%d\n", rand());
printf("%d\n", rand());
printf("%d\n", rand());
printf("%d\n", rand());
printf("%d\n", rand());
getchar();getchar();
return 0;
}