The rand command works!
Check out the source code:
#include <stdio.h>
#define MAX 100
int a[MAX];
int rand_seed=10;
/*Returns random number between 0 and 32767.*/
int rand()
{
rand_seed = rand_seed * 1103515245 +12345;
return (unsigned int)(rand_seed / 65536) % 32768;
}
int main()
{
int i,t,x,y;
/* fill array */
for (i=0; i < MAX; i++)
{
a[i]=rand();
printf("%d\n",a[i]);
}
return 0;
}
Comment:
#define MAX 100, the size of the array is 100.
int rand_seed=10, by changing the the value of the seed you will get an array with other random ganerated numbers.
Thank you all for helping me!
__________________
Thumbs up
|