ok changed some code so here is the big sha bang again..... :-P
Code:
#include <iostream>
#include <cmath>
using namespace std;
double distance (double x1, double y1, double x2, double y2) //function to figure out the distance
{
double dx = x2 - x1;
double dy = y2 - y1;
double dsquared = dx*dx + dy*dy;
double result = sqrt (dsquared);
return result;
}
double radius (double x1, double y1, double x2, double y2) //function to figure out the radius
{
double radius = distance (x1, y1, x2, y2);
return radius;
}
double circumference(double radius) //function to figure out the circumference
{
double circumference = 3.1416 * (radius * 2);
return circumference;
}
double area(double radius) //function to figure out the area
{
double area = 3.1416 * radius * radius;
return area;
}
double diameter(double radius) //function to figure out the diameter
{
double diameter = 2 * radius;
return diameter;
}
int main()
{
double x1; //variable to store the center point of the circle
double x2; //variable to store the second point on the circle
double y1; //variable to store the center point of the circle
double y2; //variable to store the second point on the circle
cout <<"Enter a center point: ";
cin >> x1 >> y1;
cout <<"Enter a point on the circle: ";
cin >> x2 >> y2;
cout <<"The distance of the circle is: "
<< distance(double x1, double y1, double x2, double y2)
<< endl;
//area return
cout <<"The area of the circle is: "
<< area(radius) << endl;
//radius return
cout <<"The radius of the circle is: "
<< radius(x1, y1, x2, y2) << endl;
//circumference return
cout <<"The circumference of the circle is: "
<< circumference(radius) << endl;
//diameter
cout <<"The diameter of the circle is: "
<< diameter(radius) << endl;
return 0;
}
ok silly question, can I have more than one variable in the parameter? or is it best ot have one parameter?
ie:
Code:
distance(double x1, double y1, double x2, double y2)
or
distance(x1)
*I still think that throwing the cumpter will help ;-P