1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
const float PI = 3.1416;
//Prototypes declaration
double distance (double, double, double, double);
double radius (double, double, double, double);
double circumference (double);
double area (double);
//Main Function
int main()
{
double x1, x2, y1, y2;
//Get a center point
cout << "Enter center of circle: ";
cin >> x1 >> y1;
//Get another point on the circle
cout<<"Enter a point on circle: ";
cin >> x2 >> y2;
double rad = radius(x1,y1,x2,y2);
cout << endl;
double cir = circumference(rad);
cout << endl;
double GetArea = area(rad);
cout << endl;
cin.get();
cout<<"Circle("<<rad<<","<<cir<<","<<GetArea<<")"<<endl;
cin.get();
return 0;
}
double distance (double x1, double y1, double x2, double y2)
{
double radius = sqrt(pow(x2 - x1 , 2.0)
+ pow(y2 - y1, 2.0));
return radius;
}
double radius (double x1, double y1, double x2, double y2)
{
double radius = distance (x1, y1, x2, y2);
return radius;
}
double circumference (double radius)
{
double circumference = PI * (radius * 2);
return circumference;
}
double area(double radius)
{
double area = PI * radius * radius;
return area;
}
|