Hello.
I am a student of C language.
How can I generate a pseudo-random real number from interval [0,1] ?
Can it be generalized to any interval? Like [0,a], where 'a' is a parameter?
I tried searching for it, I only found rand(), srand(), random(1), and randomize. None of it actually seems to work for me..
Later I actually succeded with something like
srand( (unsigned)time( NULL ) );
printf( " %6d\n", rand() );
but it only produces up to five digits integers and I cannot divide by 99999 to get it into [0,1].
Thank you.



7Likes
LinkBack URL
About LinkBacks



