FORMULA!!!!!!!

ok, not really want u to help me do my homework, just want to know the formula...

the program prompt user to input 2 point x1,x2 ,y1,y2... formula given
sqrt(pow(x1-x2,2) - pow(y1-y2,2))

a)find the distance between the 2 point..
b)find the radius, by call the distance function
c)find the circumference
d)find the area

now im stucked at radius, i dont know the formula to find the radius... by the way i need to use calling,called function to do this
Find the radius of what?
ok here's the question

The following formula gives the distance between 2 points x1,x2 and y1,y2 in the cartesian plane:
sqrt(pow(x1-x2,2) - pow(y1-y2,2))

given the center and a point on the circle, you can use this formula to find the radius of the circle. Write a program that prompts user to enter the center a point on the circle. The program should then output the circle radius, diameter, circumference and area. your program must have at least the following function:

a)distance:this function takes as its parameters four numbers that represent tow points in the plane and returns the distance between them.

b)radius:this function takes as its parameters four numbers that represent the center and a point on the circle, calls the function distance to find the radius of the circle, and return the circle radius.

c)circumference: this function takes as its parameter a number that represents the radius of the circle and returns the circle circumference.

d)area: this function takes as its parameter a number that represents the radius of the circle and return the circle area

assume the pi = 3.1416


okay, any ideas??
Here are the formulas:

a) distance, here they want you to just implement the formula: d(x,y) = |x - y| means:
distance(x1,x2,y1,y2) = sqrt((x1-y1)^2 + (x2-y2)^2)

b) radius, you have to think about the meaning of distance. after a while of thinking you should come to the conclusion: hey! in this case distance of the 2 points equals the radius! But really, think about it, because it is a serious mathematical issue.

c) circumference: read wikipedia! circ = 2 * Pi * radius

d) area: wikipedia! area = Pi * r^2

Hope this helped, Maikel
Last edited on
If (x1,y1) is the center point of the circle and (x2,y2) is a point on the circle, then the radius
of the circle is exactly the distance between those two points.
ya i know.. i did think about it that distance = radius.. then if it true i think i dont need to write the radius function but the question did ask me to write a radius function.. or the radius function is to call the distance function to return back as radius function but not distance function??
As far as I can see, radius() is nothing more than a call to distance(). [which is stupid imo, but that's what
prof wants...]
ok i think i try to call it out... thanks though
Topic archived. No new replies allowed.