move to repo.or.cz
[letusc.git] / ch2 / exercises1 / exe11.c
blob4cf23c2215e261ec9cc06f308097d97280b52232
1 /*To find whether a point lies on,inside or outside a circle */
3 #include<stdio.h>
4 #include<math.h>
5 #include<stdlib.h>
7 int main()
9 int x1,y1,rad;
10 int x,y;
11 float d;
12 int temp;
14 printf("Enter the center of the circle X1, Y1 :");
15 scanf("%d %d",&x1,&y1);
16 printf("Enter the radius of the circle:");
17 scanf("%d",&rad);
19 printf("Enter the point (x,y):");
20 scanf("%d %d",&x,&y);
22 /*computing the distance between the two points*/
23 temp = pow(x1-x,2)+pow(y1-y,2);
24 d = sqrt(temp);
27 if(d==rad)
28 printf("The point (%d,%d) lies on the circle\n",x,y);
29 else if(d<rad)
30 printf("The point lies inside the circle\n");
31 else
32 printf("The point lies outside the circle\n");
34 return 0;