For example I would like to generate 5 unique numbers between 1 & 10. The results should be 5 numbers from 1 to 10(for example 2 3 4 8 10).
If the range is very large, and the number of values you want is pretty small (like, 5 distinct values in the range 1 ... 1000000) then you can try generating random numbers in the range and throw away (unlikely) duplicates until you have 5. The problem with the "keep trying" approach is that there's a teeny tiny chance you could spend a lot of time with a string of random values that give you a lot of duplicates. For a big range of values, that's so unlikely that it's probably worth risking it unless the software is giving oxygen to trauma patients or something.