Random Numbers
Is there a function that can''t pick a random number between 2 numbers? I want something that will pick a number from 1 to 100.
Thanks.
-----------------------
Hail to the king, baby.
-----
randomize();
res = random(100) + 1;
or
srand(time(NULL));
res = rand()%100 + 1;
is this what you mean?
Arkon
[QSoft Systems]
res = random(100) + 1;
or
srand(time(NULL));
res = rand()%100 + 1;
is this what you mean?
Arkon
[QSoft Systems]
I guess, if it picks a number between 1 and 100. And is "res" the variable that it stores the number in? Also, what include file is that in?
-----------------------
Hail to the king, baby.
Edited by - Squeejee on May 8, 2001 6:21:40 PM
-----------------------
Hail to the king, baby.
Edited by - Squeejee on May 8, 2001 6:21:40 PM
-----
srand() and rand() are in stdlib.h
srand() seeds the algorithm to avoid that the same pattern is always repeated. You shouldn''t use a static number for seeding unless you really want to get the same returns in the same order everytime you run the program.
Snale
+--My humble and superior homepage
srand() seeds the algorithm to avoid that the same pattern is always repeated. You shouldn''t use a static number for seeding unless you really want to get the same returns in the same order everytime you run the program.
Snale
+--My humble and superior homepage
Snale+--My humble and superior homepage
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement