Linked Questions

123 votes
20 answers
184k views

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 ...
anand's user avatar
  • 11.4k
-2 votes
4 answers
11k views

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 ...
Abhishek Mhatre's user avatar
-3 votes
1 answer
2k views

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,...
Abdullah Abu Tasneem's user avatar
0 votes
0 answers
602 views

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 ...
abi.ravi0901's user avatar
3 votes
4 answers
4k views

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 ...
Shawn Pacarar's user avatar
0 votes
1 answer
6k views

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 ...
Cartino's user avatar
  • 41
-3 votes
2 answers
2k views

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 ...
user1368970's user avatar
-1 votes
1 answer
741 views

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 = {...
Niles's user avatar
  • 121
0 votes
3 answers
526 views

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 ...
Pxnditx YR's user avatar
-3 votes
1 answer
788 views

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 ...
James Garner's user avatar
0 votes
2 answers
439 views

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 ...
Seth's user avatar
  • 11