generating more than one random numbers

Oct 25, 2012 at 1:33pm
hi
I'm trying to generate two different random numbers in the same function but it only generates one and assigns the same number to each different variable. how can i pick two different random numbers for different variables in the same function??
Oct 25, 2012 at 1:44pm
1
2
x = rand();
y = rand();

Two random variables, x and y, with different random numbers.
Oct 25, 2012 at 1:52pm
one more thing can i use this function( assigning random values to variables) more than one time in the main function
for example i want to generate 100 points but doing it with a for loop doesnt work! the points are all the same
Oct 25, 2012 at 1:58pm
1
2
3
4
5
int array[100];
for (int x=0; x<100; x++)
{
  array[x] = rand();
}
Topic archived. No new replies allowed.