/*A program to check whether a given point lies inside the circle, on the circle or outside the circle */
#include <stdio.h>
#include <math.h>
int main()
{
int h,k,x,y,r;
float a;
printf("enter center (h,k) of a circle\n");
scanf("%d%d",&h,&k);
printf("\nenter radius\n");
scanf("%d",&r);
printf("\nenter a point to be checked\n");
scanf("%d%d",&x,&y);
a=sqrt(pow(x-h,2)+pow(y-k,2));
if (a<r)
printf("\npoint (%d, %d) lies inside the circle",x,y);
else if (a==r)
printf("\npoint (%d, %d) lies on the circle",x,y);
else
printf("\npoint (%d, %d) lies outside the circle",x,y);
printf(" having centre (%d,%d) and radius %d\n",h,k,r);
return 0;
}
No comments:
Post a Comment