C++ Primer Plus Chapter 2 Exercise 3

c plus plusHere is my solution to exercise 3. We’re going with void functions here to accomplish out task.

3. Write a C++ program that uses three user-defined functions (counting main() as one)
and produces the following output:
Three blind mice
Three blind mice
See how they run
See how they run

One function, called two times, should produce the first two lines, and the remaining
function, also called twice, should produce the remaining output.

 #include <iostream>

using namespace std;

void twoTimes();
void twice();

int main()
{
twoTimes();
twoTimes();
twice();
twice();

cin.ignore();
return 0;
}

void twoTimes()
{
cout << "Three blind mice" << endl;
}

void twice()
{
cout << "See how they run" << endl;
}
 
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s