I wonder what your teacher will think if you hand in this
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
double rand_mid(int low, int high)
{
return (double)(low+rand()%(high-low+1));
}
int main(void)
{
double x;
int i;
srand(time(NULL));
for(i=0; i<10; i++){
x = rand_mid(1, 100);
printf("A random number from 0 to 99.9: %f\n", x);
}
return 0;
}
It's a normal integer rand() generator, except the output is a double ;p I actually haven't had a need to create random doubles or floats, I'll have to give this some thought.
-Prelude