About 52 results
Open links in new tab
  1. How to generate a random int in C? - Stack Overflow

    Aug 4, 2015 · 10 STL doesn't exist for C. You have to call rand, or better yet, random. These are declared in the standard library header stdlib.h. rand is POSIX, random is a BSD spec function. The …

  2. How does rand() work? Does it have certain tendencies? Is there ...

    Aug 21, 2010 · The actual implementation of the random number generator is left unspecified, so the actual behavior is specific to the implementation. The important thing to remember is that rand does …

  3. How do I get a specific range of numbers from rand ()?

    Jul 30, 2009 · Here is my answer there, which contains the definition for my int utils_rand(int min, int max) func, which returns a random number using rand() which is in the specific range from min to …

  4. How does rand() work in C? - Stack Overflow

    Oct 28, 2015 · Finally, rand() % 50 means "call rand(), divide the result by 50, and then take the remainder". (The % is the modulus operator, which means you want the remainder.) For example, if …

  5. c++ - How does modulus and rand () work? - Stack Overflow

    Oct 24, 2013 · A second lesson is that this shows another way in which <random> is easier to use than rand() and manually computing your own distributions. The built-in uniform_int_distribution allows …

  6. rand() function in c++ - Stack Overflow

    Sep 27, 2011 · Read: The c++ rand () function gives you a number from 0 to RAND_MAX (a constant defined in ), which is at least 32767. () The modulus (%) operator gives the remainder after dividing. …

  7. c - Rand Implementation - Stack Overflow

    Jan 22, 2011 · I would like to go through how rand() and srand() functions are implemented and would like to tweak the code to modify it to my requirements. Where can i find the source code of rand() …

  8. How to use the rand function to make numbers in a specific range?

    Nov 24, 2010 · I would like to make random numbers in a specific range, like "pick a random number between 18 and 35"? How can I do that with the rand() function?

  9. What's the Right Way to use the rand () Function in C++?

    This basically just did the same as the program did in the first place but outputted a different set of numbers (which makes sense since the first number generated by rand () is always 41.) The only …

  10. How are random numbers generated in C (rand function)?

    May 13, 2021 · rand() in C is commonly implemented as a Linear Congruential Generator (LCG), but there are a lot of random number generators out there. Even though it is a classic way of generating …