I am trying to choose a string out of 4 strings randomly, and to show this string on the console. How can i do it ? For example, there is a question, if user answers it correctly, then the console will display one of the strings that i chose. I know how to choose an integer value randomly, but i could not figure out how to choose a string randomly. Please Help?
GeekTool
0
Junior Poster in Training
Recommended Answers
Jump to PostPut the strings into an array and use the randon int (0-3) as the index to retrieve one element of the array.
All 4 Replies
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
GeekTool
0
Junior Poster in Training
NormR1
563
Posting Sage
Team Colleague
GeekTool
0
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.