Hey

I'm doing a hangman project at the moment,I have a string array containing 10 words to be guessed.I can generate a random number between 0 and 9 but how do i compare this to the index of the elements to randomly pick a word???

thanks

Printable View

- 03-30-2010trentboyettepick randomly from array
Hey

I'm doing a hangman project at the moment,I have a string array containing 10 words to be guessed.I can generate a random number between 0 and 9 but how do i compare this to the index of the elements to randomly pick a word???

thanks - 03-30-2010Dino
Since you can pick a random number in the right range, just use THAT as the index into the array.

- 03-30-2010laserlight
I am not sure what is the question. Don't you already have a random index that you can immediately use?

- 03-30-2010trentboyette
Ok,i have an array with 10 words and i want to pick one of them randomly,how do i do it

- 03-30-2010laserlight
You would "generate a random number between 0 and 9" and then use that number as the index of the randomly chosen element.