Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- /*
- *Write an expression that checks if given point (x, y) is inside a circle K({0, 0}, 2)
- */
- class PointInCircle
- {
- static void Main()
- {
- float radious;
- float pointX;
- float pointY;
- bool inCircle;
- Console.WriteLine("What's circle's radious?");
- radious = float.Parse(Console.ReadLine());
- Console.WriteLine("Please enter value of X");
- pointX = float.Parse(Console.ReadLine());
- Console.WriteLine("Please enter value of Y");
- pointY = float.Parse(Console.ReadLine());
- inCircle = radious * radious - (pointX * pointX + pointY * pointY) > 0; //theorem of Pythagoras a^2 + b^2 =c^2
- if (inCircle)
- {
- Console.WriteLine("The point is in the circle!");
- }
- else
- {
- Console.WriteLine("The point is outside the circle");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement