C++ Primer Plus Chapter 2 Exercise 2

c plus plusHere is my version of chapter 2 exercise 2.

2. Write a C++ program that asks for a distance in furlongs and converts it to yards. (One
furlong is 220 yards.)


#include iostream;

using namespace std;

const int furlong = 220;
int input;
int distance;

int main()
{
cout << "Enter number of furlongs: ";
cin >> input;
int distance = input * furlong;
cout << "That is a total of " << distance <<  " yards\n";
return 0;
}

Not bad, keep moving.

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