checks whether the point is within the circle centered at (0, 0) with radius 10. For example, (4, 5) is inside the circle and (9, 9) is outside the circle, as shown in Figure below y-axis (9,9) (4,5) & (0,0) x-axis Hint: A point is in the circle if its distance to (0, 0) is less than or equal to 10. The formula for computing the distance between two points is given by √(22 − 21 )² + (32 − 3/1 )² Test your program to test all cases. Two sample runs are shown here. Enter a point with two coordinates: 4 5 Point (4, 5) is in the circle Enter a point with two coordinates: 99 Point (9, 9) is not in the circle Enter Enter
Please review the image below. Produce the program in C++. Upload screenshots of Code and Output, as well as the source code.
7
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int cx, cy, radius, x, y, distance;
cout<<"Enter the center point(cx, cy):\n";
cin>>cx>>cy;
cout<<"Enter radius of the circle:\n";
cin>>radius;
cout<<"Enter the point(x, y) to check its position\n";
cin>>x>>y;
distance = sqrt( pow( (x - cx), 2 ) + pow( (y - cy), 2 ) );
if(distance < radius)
{
cout<<"Point" <<x,y)<<"in side circle";
}
else if(distance > radius)
{
cout<<"Point"<<(x,y)<<"is not in the circle";
}
else
{
cout<<"Point"<<(x,y)<<"is on the circle";
}
return 0;
}
Step by step
Solved in 2 steps with 1 images