Hi everyone.

Can anyone please guide me on how can I generate a random number from a group of prset numbers.


For example:-

There is a group of preset numbers:-
1,5,18,100,127,500,626,929.

I want to generate a random number from this group....is there anyway in which we could do this?

Do you mean how can you pick up a random number from given sequence of numbers?
follow this thread :http://www.daniweb.com/forums/thread198944.html

Lemme try and explain it in more details.
I provide the program with the following group of numbers:-

1,5,18,100,127,500,626,929.

Now, all I want is that the output should be a random number from one of these numbers:-

1,5,18,100,127,500,626,929.

This is quite simple actually,

Put all of the Numbers into a array,

Then Generate a random number between 0 and {The Number of Numbers in your array } Including 0 too, So then you can use array [randomnumberindex] to get a random number out,

This is quite simple actually,

Put all of the Numbers into a array,

Then Generate a random number between 0 and {The Number of Numbers in your array } Including 0 too, So then you can use array [randomnumberindex] to get a random number out,

Oh...lol...okay...yeah..that was simple. :D

This question has already been answered. Start a new discussion instead.