About 839,000 results
Open links in new tab
  1. 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 (%) …

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

    Many implementations of rand() cycle through a short list of numbers, and the low bits have shorter cycles. The way that some programs call rand() is awful, and calculating a good seed …

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

    Oct 28, 2015 · How does rand () work in C? [closed] Asked 9 years, 8 months ago Modified 5 years, 2 months ago Viewed 33k times

  4. generate a random number between 1 and 10 in c - Stack Overflow

    Jul 24, 2013 · randomnumber = rand() % 10; printf("%d\n", randomnumber); return 0; } This is a simple program where randomnumber is an uninitialized int variable that is meant to be printed …

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

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

  7. Using stdlib's rand() from multiple threads - Stack Overflow

    Mar 14, 2013 · The function rand_r() is supplied with a pointer to an unsigned int, to be used as state. This is a very small amount of state, so this function will be a weak pseudo-random …

  8. How do I generate a random integer in C#? - Stack Overflow

    Jun 21, 2022 · { Random rand = new Random((int)DateTime.Now.Ticks); return rand.Next(min, max); } if you are looking for random number generator for normal distribution, you might use a …

  9. How do I use rand_r and how do I use it in a thread safe way?

    Oct 20, 2010 · 26 I am trying to learn how to use rand_r, and after reading this question I am still a little confused, can someone please take a look and point out what I'm missing? To my …

  10. How do I generate a random number for each row in a T-SQL select?

    I need a different random number for each row in my table. The following seemingly obvious code uses the same random value for each row. SELECT table_name, RAND() magic_number …