# Thread: I don't know how to do it!

1. ## I don't know how to do it!

in this code I try to perform number of commands;

first getting tow points from the user.one represent the center of a circle and the other represent a point on the same circle.
then I must use 4 functions . and then to print on the screen these solutions:
r=radius d=diameter , c=circumference a= area. t
I have many bugs but I have no clue how to solve it , thanks for the helpers.

Code:
```double distance(double x1, double x2, double y1, double y2)
{
double a=0 ,b=0 ,c=0, d=0 ,e=0 ;
a= x2 -x1;
b= y2 -y1;
c = a*a;
d = b*b;

e=c+d;

return sqrt(e);

}

double radius(double r_x1, double r_y1, double r_x2, double r_y2)
{
double  r =0;

r = distance(r_x1, r_x2, r_y1, r_y2);

return r;
}

double circumference(double r)

{
double  pai=3.1416, circ=0;

r = distance;
circ = rad * pai * 2;

return circ;
}

double area(double r)

{
double rad = distance, pai =3.1416, c=0;

return r;
}

int main()

{
double x1=0, x2=0, y1=0, y2=0, D=0;

scanf("%g %g %g %g", &x1, &y1, &x2,&y2);

D = distance(x1,x2,y1,y2) * 2;

printf("R = %g \n ",distance(x1,x2,y1,y2));
printf("D = %g \n" , 2* distance(x1,x2,y1,y2));
printf("C = %g \n ",circ(r));
printf("A = %g \n", area r));

return 0;

}```

2. printf("C = %g \n ",circ(r));
printf("A = %g \n", area r));
variable r is not declared, so you should declare it first, before using or passing to any method(function).

double area(double r)

{
double rad = distance, pai =3.1416, c=0;
....
there is no variable called distance, you have a method called distance, so you cannot assign the variable the method name. you should call it with passing some arguements.

These are two basic errors you get.... fix them, and ur done

3. thank u for the help but, I didn't understand accuratly what to do.....

4. Originally Posted by sing0

Code:
```#include<stdio.h>
#include<math.h>
double distance(double x1, double x2, double y1, double y2)
{
double a=0 ,b=0 ,c=0, d=0 ,e=0 ;
a= x2 -x1;
b= y2 -y1;
c = a*a;
d = b*b;

e=c+d;

return sqrt(e);

}

double radius(double r_x1, double r_y1, double r_x2, double r_y2)
{
double  r =0;

r = distance(r_x1, r_x2, r_y1, r_y2);

return r;
}

double circumference(double r)

{
double  pai=3.1416, circ=0;

r = distance; // distance is a function, so you should call it like you have done in radius function
circ = rad * pai * 2; // declare rad variable in this function

return circ;
}

double area(double r)

{
double rad = distance/*incorrect calling*/,pai =3.1416, c=0;

return r;
}

int main()

{
double x1=0, x2=0, y1=0, y2=0, D=0;

scanf("%g %g %g %g", &x1, &y1, &x2,&y2);

D = distance(x1,x2,y1,y2) * 2;

printf("R = %g \n ",distance(x1,x2,y1,y2));
printf("D = %g \n" , 2* distance(x1,x2,y1,y2));
printf("C = %g \n ",circ(r)); // declare r variable
printf("A = %g \n", area (r));

return 0;

}```
I've pointed out the errors. Remove them.