Newbie Question About Rand()
Hi all,
I''m trying to get a random number between 1 and 100 with rand but I don''t know how to change the RAND_MAX value, or at least I think that is what I need to change.
I try to change it just by putting RAND_MAX = 100 in my program but this just gives me errors.
Please help me. I know its probably something easy but I have know idea.
Thanks
Dan
There''s no max in rand, take this peace of code for example:
float a = rand()%100
this vill give you a random number between
0-99 or maybe it was 0-100 or 1-100, well you''ll probably find that out yourself.
float a = rand()%100
this vill give you a random number between
0-99 or maybe it was 0-100 or 1-100, well you''ll probably find that out yourself.
Hi,
It has a max value I think, something like 32276 or something. Not sure but there is a value for RAND_MAX.
It has a max value I think, something like 32276 or something. Not sure but there is a value for RAND_MAX.
Hello from my world
Oh I must have misinterpreted the MSDN. This is what it says.
"The rand function returns a pseudorandom integer in the range 0 to RAND_MAX. Use the srand function to seed the pseudorandom-number generator before calling rand."
So I assumed that I had to change RAND_MAX to set what the maxime number could be.
Dan
"The rand function returns a pseudorandom integer in the range 0 to RAND_MAX. Use the srand function to seed the pseudorandom-number generator before calling rand."
So I assumed that I had to change RAND_MAX to set what the maxime number could be.
Dan
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement