
Originally Posted by
Mentat
Just in case anyone feels like throwing a tidbit of information my way while I scrounge the interweb: I'm trying to find a function that will generate a random number between two int variables.
Code:
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main (void)
{ int val, min = 10, max = 30, i;
srand(time(NULL); // create new random sequence
for (i = 1; i < 10; i++)
{ // get random number between min and max
val = ( rand() % (max - min)) + min;
// display new number
printf ("%d\t",val); }
return 0; }