C Program :
Given coordinates of center and radius of a circle and a point P(x,y). Write a prog. to check P is inside, outside or on the circle.
C Programming -->
/* PROG. TO CHECK GIVEN POINT IS INSIDE, OUTSIDE OR ON THE CIRCLE
*/
/* GIVEN COORDINATES OF CENTRE OF CIRCLE AND POINT*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
main()
{
int r,x,y,p,q;
float d;
clrscr();
printf("enter radius of circle and coordinates of centre");
scanf("%d%d%d" ,&r,&p,&q);
printf("\n enter coordinates of point");
scanf("%d%d" ,&x,&y);
d= sqrt((x-p)*(x-p)+ (y-q)*(y-q)); /* distance of point from centre */
if(d<=r)
{
4
if(d«r*r))
printf("points is inside the circle");
else
printf("point is on the circle");
}
else
printf("point is outside the circle");
getch();
}
|