1. ## Random number generator

so, for this assignment they introduce the rand() function and also(finally) other libraries to use. anyway, the first program is as follows:

Write a program that will print out 10 random integers between 10 and 25. Prompt the user to enter the seed from which the random sequence will grow.

i used an example out of my text, but naturally it didn't work. i also asked my t.a.'s about it and they didn't know how to do it either. this left me thrilled. anyway, i was wondering what anybody thought of this.

Code:
```#include <stdio.h>
#include <stdlib.h>

int main()
{

int x, i,z;

printf("Enter a number between 10 & 25.\n");
scanf("%d", x);

printf("10 random numbers between values are as follows:\n");

for(i=0; i<10; i++)
{
z=10 + (srand(x) % 25);
printf("%d\n", z);
}

return 0;
}```

2. You only seed rand once. That is to say, you only call srand once. Then to get a number, you call rand.

Quzah.

3. cool, i got it. thanks.

Code:
```#include <stdio.h>
#include <stdlib.h>

int main()
{
int seed, i,z;

printf("RAND_MAX = %d\n", RAND_MAX);

printf("Enter seed:");
scanf("%d", &seed);

srand(seed);

printf("10 random number between values are as follows:\n");

for(i=0; i<10; i++)
{
z=10 + (rand() % 16);
printf("%d\n", z);
}

return 0;
}```

4. Put srand up above the for loop.

Add the ampersand '&' in front of x in the scanf() line of code.

Since rand() % N, will give you 0 to N-1 in range, you need to add ten and mod '%' 25 in your rand() line of code.

For example, if I wanted to get a range of 1 to 6, I'd use: rand() % 6 + 1. (rand % 6 by itself, would give me numbers ranging from 0 to 5).