How can I make my code choose from random words to produce an answer or output? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How can I make my code choose from random words to produce an answer or output?

20th Apr 2017, 6:56 PM
Avela Zolile Mdingi
Avela Zolile Mdingi - avatar
2 Answers
+ 22
As @Mattias suggested, you should use external file/db for large collection of words. For small collection, here are some sample codes of generators in C++: Credits: Pixie, Hatsy Rei, Maz, StillSoul https://code.sololearn.com/cMArmlhta6l4/?ref=app https://code.sololearn.com/cCAyuTHiI4tx/?ref=app https://code.sololearn.com/cVVneCFi0q5d/?ref=app https://code.sololearn.com/cSY5Ob4m8isM/?ref=app
20th Apr 2017, 7:16 PM
Shamima Yasmin
Shamima Yasmin - avatar
+ 1
Well, you need a source to get the words from, a file or a database. Then generate a random number and use the word att that position.
20th Apr 2017, 7:08 PM
Mattias Eriksson
Mattias Eriksson - avatar