write a c++ program that reads the x,y coordinates
write a c++ program that reads the x,y coordinates of a point. Then you program should determine wither this point lies inside a circle with radius equal 5 and centered at the point (1,2) or not.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Mar 6, 2013, 11:04 AM
Hemant SrivastavaPosted Mar 6, 2013, 11:01 AM
#include
#include
#include
using namespace std;
int main ()
{
int PointX = 3;
int PointY = 5;
bool result = IsPointWithinCircle(1,2,5, PointX, PointY)
if(result == true)
cout<<"Point is within";
else
cout<<"Point is outside";
return 0;
}
public bool IsPointWithinCircle(int CenterX, int CenterY, int radius, int PointX, int PointY)
{
bool IsPointWithin = false;
float dist = sqrt( (CenterX - PointX)* (CenterX - PointX) + (CenterY - PointY)* (CenterY - PointY));
if (dist > radius)
{
IsPointWithin = true;
}
return IsPointWithin;
}