#include <iostream>
usingnamespace std;
double getRadius();
double findArea();
double findCircumference();
int main()
{
double radius; //the radius of the circle
double area; //the area of the circle
double circumference; //the circumference of the circle
//get the value of the radius from the user..
radius = getRadius();
//determine the area and circumference
area = findArea();
circumference = findCircumference();
//output the results
cout << "A circle of radius " << radius << " has an area of: " << area << endl;
cout << "and a circumference of: " << circumference << endl;
return 0;
}
double getRadius(double n)
{
cout << "Please enter the radius of the circle: ";
cin >> n;
return n;
}
double findArea(double n)
{
double area;
area = 3.14159*n*n;
return area;
}
double findCircumference(double n)
{
double circumference;
circumference = 2 * 3.14159*n;
return circumference;
}
#include <iostream>
// using namespace std; // avoid, just use std::cout etc.
constdouble PI = 3.14159 ; // avoid magic numbers
double getRadius();
// double findArea();
double findArea( double radius ) ;
// double findCircumference();
double findCircumference( double radius );
int main()
{
// double radius; //the radius of the circle
// double area; //the area of the circle
// double circumference; //the circumference of the circle
//get the value of the radius from the user..
constdouble radius = getRadius(); // as far as possible, initialise at point of definition
//determine the area and circumference
// area = findArea();
constdouble area = findArea(radius) ;
// circumference = findCircumference();
constdouble circumference = findCircumference(radius);
//output the results
std::cout << "A circle of radius " << radius << " has an area of: " << area
<< "\nand a circumference of: " << circumference << '\n' ;
}
// double getRadius(double n)
double getRadius()
{
double radius ; // *** added ***
std::cout << "Please enter the radius of the circle: ";
std::cin >> radius ; // n;
return radius ; // n;
}
double findArea( double radius )
{
constdouble area = PI * radius * radius ; // as far as possible, initialise at point of definition
return area;
}
double findCircumference( double radius )
{
return 2 * PI * radius ; // or return an anonymous result
}