[QUOTE]but if i need to apply that in my work, how can i do it ??[/QUOTE]
Generate the numbers, then shuffle them randomly. For example, see [URL="http://www.daniweb.com/software-development/c/threads/346402"]this thread[/URL], or [URL="http://www.daniweb.com/software-development/c/threads/27314"]this thread[/URL]. Read More

however if all the numbers are not in the requirements random shuffle wont work.
If the above threads dont solve your problem,you would need to go for finding duplicates and there are several algorithms to do that.All depends on the application of the code,as complexity of the algorithms makes them specific for different purposes

What I mean is that suppose you want 6 nos from a range of 1-1000,random shuffle would have to be modified.

There's nothing about that use case that would require random shuffle to be modified. Taking a sample of 6 numbers from a randomly shuffled array of 1000 is trivial even on memory constrained systems; there's no requirement that you must use all of the numbers from the sequence.

It's also a use case where searching for duplicates in the result set is likely to be much faster than a random shuffle due to the small size of the result set and size of the result set relative to the range. In other words, you're correct that checking for duplicates and re-generating the random number if necessary is probably the better option given an assumption that the range is large and the sample set is small:

There's an implicit assumption that there are no duplicates in seq as it's generated using a random shuffle. The values of num are coming in from user input, so I added a little insurance to account for accidental duplicates. It also has the benefit of breaking the inner loop early and thus being slightly faster, but that's not a big win for small arrays.

For each number it has to be inserted on the next line till 1=6, is there a way for the numbers to be inserted on a single line..

for this method on each line its starting at the left hand side, i tried to use the \t code for it to be a tab away from the left, it does not work, what can be done for that ?
But i prefer if its possible for it to be on a single line !
thanks