Point on the circle.

 PROGRAM TO FIND WHERE THE POINT WILL LIE IN CIRCLE(outside,inside or on)

#include<stdio.h>
#include<math.h>
int main()
{
    float x,y,c1,c2,r,d;
    printf("enter the coordinates of centre = ");
    scanf("%f%f",&c1,&c2);
    printf("enter the 2 coordinates = ");
    scanf("%f%f",&x,&y);
    printf("enter radius = ");
    scanf("%f",&r);
    d=sqrt(pow((x-c1),2)+pow((y-c2),2));
    if(d>r)
    {
        printf("outside the circle ");
    }
    else if(d<r)
    {
        printf("inside the circle ");
    }
    else
    {
        printf("on the circle");
    }
    return 0;
}

OUTPUT :

enter the coordinates of centre = 0
0
enter the 2 coordinates = 5
7
enter radius = 6
outside the circle

CONCEPT OF THE QUESTION IS:

d=sqrt((x-c1) *(x-c1) +(y-c2) *(y-c2))


if distance (d) is less than radius(r) = inside.
if distance(d) is greater than radius (r) = outside.
if distance(d) is equal to the radius(r) = on the circle. 

Comments