circles - endl cout<<"What is the radius of the...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
// Demo program for computing area and circumference of a circle #include <iostream> using namespace std; const double PI = 3.1415926; // ratio of circum to diam of a circle int main() { double radius; // radius of a circle, any linear units double area; // area of same circle, square units double circum; // circumference of same circle, same linear units cout << "This program computes the area and circumference of a circle." <<
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: endl; cout << "What is the radius of the circle? "; // prompt for radius cin >> radius; area = PI*radius*radius; // compute area using PI*r^2 circum = 2*PI*radius; // compute circumference using 2*PI*r cout << "Area:\t\t" << area << endl; // output results cout << "Circumference:\t" << circum << endl; cout << "(Circumference in same units as input; area in square units.)" << endl; return 0; }...
View Full Document

This document was uploaded on 02/10/2011.

Ask a homework question - tutors are online