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
|
#include <iostream>
#include <iomanip>
#include <cmath>
#include <math.h>
using namespace std;
double distance(int x1, int x2, int y1, int y2);
double radius(int x1, int x2, int y1, int y2);
double circumference(double radius);
double area(double radius);
int main()
{
int x1,x2,y1,y2;
double rad, dis, cir, a;
cout << "Enter the x-coordinate for the center of the circle: ";
cin >> x1;
cout << "Enter the y-coordinate for the center of the circle: ";
cin >> y1;
cout << "Enter the x-coordinate for the point on the circle: ";
cin >> x2;
cout << "Enter the y-coordinate for the point on the circle: ";
cin >> y2;
dis = distance(x1,x2,y1,y2);
rad = radius(x1,x2,y1,y2);
cir = circumference(rad);
a = area(rad);
cout << "\n\nThe distance between the two points is: " << dis << endl;
cout << "The radius of the circle is: "<< rad << endl;
cout << "The circumference of the circle is: " << cir << endl;
cout << "The area of the circle is: "<< a << endl;
return 0;
}
double distance(int x1, int x2, int y1, int y2)
{
double dist = sqrt(pow(x2-x1),2)+ pow(y2-y1),2);
return dist;
}
double radius(int x1, int x2, int y1, int y2)
{
return distance(x1,x2,y1,y2);
}
double circumference(double rad)
{
double pi = 3.1416;
return (pi*rad*2);
}
double area(double rad)
{
double pi = 3.1416;
return (pi*rad*rad);
}
|