I take five random numbers, each with value in [0-9].
Why do I get same value more than once?
Then, Why not?
Each value has same* probability. What you pick for the first number has no effect* on what the next number can get.
If you want no value to appear more than once, then you have a different problem. For that, I would put numbers 0-9 into array, shuffle the array, and then pick five first elements.
* Technically, with rand(), there is no true randomness, but that is not the issue here.
In my upper code I whish two array with rand numbers if they are
in array 1 = 0 0 3 2 7
in array 2 = 2 4 1 9 0
the result is 0 0 2 (and not only 0 2) why?
How must modify this under code with srand to have a right result?
In the last code (without srand) even if in the array2 there are two equal numbers (8) the result is right 5 8 (and not 5 8 8..)
I wish to have the same with use of srand without repeated numbers...