Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a c++ algorithm for the problem below. (Not an actual code - jus verbal in

ID: 3786267 • Letter: W

Question

Write a c++ algorithm for the problem below. (Not an actual code - jus verbal insructions of what in put is needed, what output is expected the step by step process and the test data)

A point is considered to be inside a circle if the point’s distance from the center is less than or equal to the radius. Create a process that will take (x, y) coordinates for the center of a circle, the radius of the circle, and the (x, y) coordinates of a point then determine whether the point is inside the circle.

Explanation / Answer

Algorithm PointInOrOutOfCircle(centX, centY, radius, X, Y)
//Input: The centX, centY points which represent the center of the circle,
//       The radius which represents the radius of the circle.
//       The X, Y points which represent the point to be decided on.
//Output: Returns true if the point is inside the circle, false otherwise.      

   dist = sqrt((centX - X)^2 + (centY - Y)^2)   //Calculates the distance between the two points.
   if(dist <= radius)   //If the points distance from center is less than or equal to radius
       return true;   //Conclude the point is inside the circle, and return true.
   return false;       //Return false otherwise.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote