hello, i need to generate a random number smaller than 100. how can i do it. i found a rand() function but i can't specify the upper limit!
i also thought of making a function wich would generate a random nr (with the rand() function) and then check if that nr is smaller than 100, if it is then pass it to my int, if not generate another nr, but a think this may take a lot of time!
make use of % operator with rand() function
You might want to use srand() so that you get different sequences. srand() and rand() are in <cstdio>.
There's an FAQ entry on the subject.