It's an assignment I have to deliver, I'm so beginner and really need help!
This is the question asked to solve:
https://s23.postimg.org/izwxeounv/question.jpg
And this is the code I wrote:
#include <iostream>
#include <cmath>
using namespace std;
double distance (int xd1, int xd2, int yd1, int yd2)
{
double d;
d = sqrt (pow((xd2-xd1),2)+pow((yd2-yd1),2));
return d;
}
double radius (int xr1, int xr2, int yr1, int yr2)
{
double r;
r = distance (xr1, xr2, yr1, yr2);
return r;
}
double circumference (double r)
{
double c;
c = 2*3.14*r;
return c;
}
double area (double r)
{
double rad,a;
rad = radius (xd1, xd2, yd1, yd2);
a = 3.14*pow(rad, 2);
return a;
}
int main()
{
int xd1,yd1,xd2,yd2;
cout<< "Enter the center and a point on the circle like this: X1 Y1 X2 Y2: ";
cin>>xd1>>yd1>>xd2>>yd2;
double r=radius(xd1, xd2, yd1, yd2);
cout<<"The radius = "<<r<<endl;
cout<<"The diameter = "<<r*2<<endl;
cout<<"The circumference = "<<circumference(r)<<endl;
cout<<"The area = "<<area(r);
return 0;
}