Does anyone know how to write code in C++ that could allow a selection of numbers to be selected between two values.
for example i wish for a code that would allow any value to be selected between 2 and 30 for various iterations
Well, let's say you want to generate a value between a and b. What you could do is generate a number between 0 and (b-a) and than adding it to a. This way your smallest number will be a and your biggest will be b. Hope that helps. Remember that Visual C doesn't have the random() and randomize() functions so you'll have to use srand() and rand(). For more detail on these 2 functions see thread116-275510
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.