exercise 1.27 solution

#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main() {
	int radius;
	
	// prompt user to enter the radius
	cout << "Enter the radius: ";
	cin >> radius;

	int diameter = 2 * radius;
	int circum = 2 * radius * 3.14159;
	int area = 3.14159 * radius * radius;

	// display the results
	cout << "Diameter: " << diameter << endl;
	cout << "Circumference: " << circum << endl;
	cout << "Area: " << area << endl;

	return 0;
}
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