< Previous | Contents | Next >
The results of the Instructions program are pretty basic—a few lines of text that are the beginning of some game instructions. From the looks of the output, Instructions seems like a program you could have written way back in Chapter 1. But this program has a fresh element working behind the scenes—a new function. Take a look at Figure 5.1 to see the modest results of the code.
Figure 5.1
The instructions are displayed by a function.
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 instructions.cpp.
// Instructions
// Demonstrates writing new functions #include <iostream>
using namespace std;
// function prototype (declaration) void instructions();
int main()
{
instructions(); return 0;
}
// function definition void instructions()
{
cout << "Welcome to the most fun you’ve ever had with text!\n\n"; cout << "Here’s how to play the game.. .\n";
}