About 52 results
Open links in new tab
  1. 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 …

  2. ¿Cual es la diferencia entre rand y srand?

    Jul 22, 2018 · me gustaria si me pudieran explicar bien cual es la diferencia, me confundo mucho con rand y srand, ¿cual es la diferencia? He buscado en otros sitios, pero confundo más. …

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

    Oct 28, 2015 · The rand() function takes the 'seed' to produce the next random output value, then generates a new 'seed' from the old 'seed' then returns the 'random' output value

  4. How to generate a random int in C? - Stack Overflow

    Aug 4, 2015 · The difference between rand and random is that random returns a much more usable 32-bit random number, and rand typically returns a 16-bit number. The BSD manpages …

  5. c - How does srand relate to rand function? - Stack Overflow

    I assume it would look something like rand (srand (time (null)); It's like initializing a variable without using it to me. srand is being initialized, but I don't see it being used. Does rand …

  6. 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 …

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

    Sep 27, 2011 · The c++ rand () function gives you a number from 0 to RAND_MAX (a constant defined in <cstdlib>), which is at least 32767. (from the c++ documentation) The modulus (%) …

  8. ¿Cómo generar números aleatorios con srand y rand en C dentro …

    Oct 12, 2020 · Y con dado = 1 + rand() % 6 puedo generar un número aleatorio entre 1 y 6 para la variable dado. No entendí el razonamiento para llegar a la fórmula de dado pero funciono. …

  9. Generate a value between 0.0 and 1.0 using rand () - Stack Overflow

    The OP's reasoning for trying it was wrong, but had this been necessary, the UB could've been avoided by adding 1.0 instead of 1, which would coerce RAND_MAX to double type and so …

  10. Why do I always get the same sequence of random numbers with …

    22 To quote from man rand : The srand () function sets its argument as the seed for a new sequence of pseudo-random integers to be returned by rand (). These sequences are …