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
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
Since you can pick a random number in the right range, just use THAT as the index into the array.
I am not sure what is the question. Don't you already have a random index that you can immediately use?
Ok,i have an array with 10 words and i want to pick one of them randomly,how do i do it
You would "generate a random number between 0 and 9" and then use that number as the index of the randomly chosen element.