When I am trying to generate a random number 0 through int
:
//Populate Currently Allocated Reasource for each customer
for (i = 0; i < NUMBER_OF_CUSTOMERS; i++)
{
printf("%d:[ ",i);
for (j = 0; j < NUMBER_OF_RESOURCES; j++)
{
allocation[i][j] = rand() % maximum[i][j];
printf("%d ",allocation[i][j]);
}
printf("] \n\n");
}
I get a floating point exception when maximum[i][j]
is 0.
Are there any better means of creating a random number without the floating point error
caused by rand() % 0
?
EDIT: When maximum is 0, the random number output should just be 0.