counter

Free Hit Counter

c program to check position of point in a circle


Q:Write a c program to check whether a given point is outside, inside or on the circle when radius and coordinates of points are input



#include
#include
void main()
{
int x,y,r,d;
clrscr();
printf("enter x co ordinate");
scanf("%d",&x);
printf("enter y co ordinate");
scanf("%d",&y);
printf("enter radius");
scanf("%d",&r);

d=(x*x)+(y*y);
r=r*r;
if(d==r)
{
printf("point is on the circle");
}
else if(d>r)
{
printf("point is outside the circle");
}
else if(d
{
printf("point is inside the circle");
}
getch();
}

No comments:

Post a Comment