//Mad lib
// Creates a story based upon user input
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
string askText(string prompt);
int askNumber(string prompt);
void tellStory(string name, string noun, int number, string bodyPart,string verb);
int main()
{
cout << "Welcome to Mad Lib.\n\n";
cout << "Awnser the following questions to help create a new story. \n";
string name = askText("Please enter a name: ");
string noun = askText("Please enter a plural noun: ");
int number = askNumber("Please enter a number: ");
string bodyPart = askText("Please enter a body part: ");
string verb = askText("Please enter a verb ");
tellStory(name , noun , number , bodyPart , verb);
system("PAUSE");
return 0;
}
string askText(string prompt)
{
string text;
cout << prompt;
cin >> text;
return text;
}
void tellStory(string name, string noun, int number, string bodyPart, string verb)
{
cout << "\nHere's your story:\n";
cout << "The famous explorer ";
cout << name;
cout << " had nearly given up a life-long quest to find\n";
cout << "The Lost City of ";
cout << noun;
cout << " when one day, the ";
cout << noun;
cout << " found the explorer .\n";
cout << "Surrounded by ";
cout << number;
cout << "" << noun;
cout << ", a tear came to ";
cout << name << "'s ";
cout << bodyPart << ".\n";
cout << "After all this time, the quest was finally over. ";
cout << "And then, the ";
cout << noun << "\n";
cout << "promply devoured ";
cout << name << ".";
cout << "Moral of the story? Be careful what you ";
cout << verb;
cout << " for.";
}
Lilgenski16
0
Newbie Poster
Recommended Answers
Jump to PostYou were asking about
askNumber
, nottellStory
.What you point out are the declarations not the definitions. Declarations give the signature of the function (parameters, return type) and definitions provide the functional body for the function. Lines 30 and 38 start the definitions of
askText
andtellStory
, respectively.
All 4 Replies
L7Sqr
227
Practically a Master Poster
Lilgenski16
0
Newbie Poster
L7Sqr
227
Practically a Master Poster
Lilgenski16
0
Newbie Poster
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.