< Previous | Contents | Next >

Introducing the Mad Lib Game

The Mad Lib game asks for the users help in creating a story. The user supplies the name of a person, a plural noun, a number, and a verb. The program takes all of this information and uses it to create a personalized story. Figure 5.8 shows a sample run of the program.



image

Figure 5.8

After the user provides all of the necessary information, the program displays the literary masterpiece.

Introducing the Mad Lib Game 181


You can download the code for this program from the Course Technology website (www.courseptr.com/downloads). The program is in the Chapter 5 folder; the filename is mad_lib.cpp.


 

Setting Up the ProgramThe main() FunctionThe askText() FunctionThe askNumber() FunctionThe tellStory() Function