RAND_MAX works like a charm
however i was trying to write the function using drand48 and erans48, can you tell me what am i doing wrong
Code:
#include <stdio.h>
#include <time.h>
int main(void)
{
int number;
float random_factor;
float random_number;
random_number=0;
printf("What is the number?");
scanf("%d",&number);
drand48( (unsigned int)time(NULL));
random_factor=erand48();
random_number=random_factor*(float)number;
printf("\n Number is %d",number);
printf("\nRandom Factor is %f",random_factor);
printf("\nRandom Number is %f",random_number);
return 0;
}
but i get the following results
What is the number?10
Number is 10
Random Factor is 0.000000
Random Number is 0.000000[