Linked Questions
11 questions linked to/from Random number c++ in some range
123 votes
20 answers
184k views
Generate random numbers uniformly over an entire range
I need to generate random numbers within a specified interval, [max;min]. Also, the random numbers should be uniformly distributed over the interval, not located to a particular point. Currenly I am ...
-2 votes
4 answers
11k views
Generation of random number(within a limit) code overshooting the upper limit [duplicate]
My Computer science C++ book says that to generate random numbers with a lower limit (in this case, 15)and upper limit(in this case, 50), we have to use the following code. But when I used it I got ...
-3 votes
1 answer
2k views
Generating Random Number in Range [duplicate]
I know how to generate Random numbers in C++. Like, int num = rand()%(1000)+1; Then the random number will be between 1 to 1000. But My Questions are- How can I generate numbers between two fix range,...
0 votes
0 answers
602 views
How to fix rand()/RAND_MAX in a method that always produces 0.0000000? [duplicate]
I need to produces numbers between 0 and a max (seen in code as assetMax). In the code, the rand()/RAND_MAX always produces 0 and I cannot seem to figure out why. I use the rand() function immediately ...
3 votes
4 answers
4k views
Evenly distribute values into array
I have a fixed size boolean array of size 8. The default value of all elements in the array is false. There will be a number of truth values to fill between 1-8. I want to distribute the truth values ...
0 votes
1 answer
6k views
Need to generate a unique 5 digit number from 00001 to 99999 in C++ [duplicate]
We will modify part of the existing menu logic to generate an ID for the user. This user ID will be of the type int, and will be 5 digits in length. The values are 00001 – 99999, and should appear ...
-3 votes
2 answers
2k views
Error with rand function C++ [closed]
I have a hangman program, but I'm having issues with randomly choosing a word out of the list... I get the errors: -error C2661: 'rand' : no overloaded function takes 1 arguments -IntelliSense: too ...
-1 votes
1 answer
741 views
Random colors from array
Is it possible to assign a random color to a string of leds? I have a string of 10 WS2812 leds, and they can be any color I stated in the array With the FastLed lib a color can be a name. colorLed = {...
0 votes
3 answers
526 views
I need to get a random number in the range from a to b with n decimal places
I need a function that returns me a random number with n decimal places Example: int aleatorio(int li, int ls) { return rand()%(ls+1-li)+li; } What i want is: float new_random(int start, int ...
-3 votes
1 answer
788 views
random number generator in interval
I am interested in generating a random number between an interval [a b] for a given size; for this, I will move my elements in an array by this random number. For example, if my size is 4 -- I will ...
0 votes
2 answers
439 views
Turning on random LEDs from a class
For a school project I need to randomly turn on LEDs in a color that is randomly chosen. So for example you can choose between red, blue, yellow and green. Then you need to pick one color randomly and ...