Random(0,2) gives bad results All I need to do is generate a random integer between 0 and 3 for example.
I am using this function:

void Crossover(int parents[2][3])
{
  int ranDpart;
  int ranDparent;
  for(int i=0; i&lt;10; i++)
  {
    for(int j=0; i&lt;3; j++)
    {
      ranDpart = random(0,3);
      ranDparent = random(0,2);
      newGen[i][j] = parents[ranDparent][ranDpart];
    }
  }
}


where as you see parents is input with size of 2x3 and newGen is 10x3 2D array. As seen here in the code, this function is supposed to randomly take one of parent and a part of this parent to make a new "child". Am I doing something wrong? I think that random gives me bad results. I tried some online compiler and random gives me numbers like "1804289383" even if I tried to make it long. Can you guys help me with random int?
stdlib.h defines a few psuedo-random number functions. I am not familiar with a random function taking two arguments, presumably the low and high end of the desired range, that you've specified in your code.

For what it's worth, in plain old C use the modulo operator to achieve the range you want using stdlib's srand and rand functions:

/* seed psuedo-random number generator during setup with something */
srand(0xdeadbeef);


and in your function simply use modulus to get your range:

int ranDpart = rand() % 3; /* range: 0,1,2 */
int ranDparent = rand() % 2; /* range: 0,1 */


If your ranges should be inclusive e.g. [0,3] and [0,2] then

int ranDpart = rand() % 4; /* 0,1,2,3 */
int ranDparent = rand() % 3; /* 0,1,2 */