You need to call srand()
once, to randomize the seed, and then call rand()
in your loop:
#include <stdlib.h>
#include <time.h>
#define size 10
srand(time(NULL)); // randomize seed
for(i=0;i<size;i++)
Arr[i] = rand()%size;
More Related Contents:
- srand() — why call it only once?
- How does srand relate to rand function?
- Random numbers in C
- Why do I always get the same sequence of random numbers with rand()?
- How to generate a random integer number from within a range
- How to generate a random int in C?
- Recommended way to initialize srand?
- Unique random number generation in an integer array [duplicate]
- What common algorithms are used for C’s rand()?
- How do I get a specific range of numbers from rand()?
- Rand() % 14 only generates the values 6 or 13
- What’s the best way to return a random line in a text file using C?
- How to generate random float number in C
- Rand Implementation
- Why do I get the same result with rand() every time I compile and run? [duplicate]
- How to generate random numbers in parallel?
- Why does rand() always return the same value? [duplicate]
- Generating a random bit – lack of randomness in C rand()
- Is there an alternative to using time to seed a random number generation?
- Does “n * (rand() / RAND_MAX)” make a skewed random number distribution?
- How to use /dev/random or urandom in C?
- How often should I call srand() in a C++ application?
- srand function is returning same values
- Why is rand() not so random after fork?
- Trying to generate 9 digit numbers with each unique digits
- implementation of rand()
- C program – srand() [duplicate]
- Does stdlib’s rand() always give the same sequence?
- How predictable is the result of rand() between individual systems?
- How does calling srand more than once affect the quality of randomness?