settingsAccountsettings
Menusettings

Q: C# Point in a Circle

+4 votes

Write an expression that checks if given point (xy) is inside a circle K({0, 0}, 2).

Examples:

point in a circle in c#

asked in C# category by user hues
edited by user golearnweb

1 Answer

+1 vote

Here is my solution:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


class PointInACircle
{
    static void Main()
    {
        Console.WriteLine("Enter point x for circle K({0, 0}, 2):");
        double x = double.Parse(Console.ReadLine());
        Console.WriteLine("Enter point y for circle K({0, 0}, 2):");
        double y = double.Parse(Console.ReadLine());
        bool check = Math.Pow((x - 0), 2) + Math.Pow((y - 0), 2) <= Math.Pow(2, 2);
        Console.WriteLine("Point inside? {0}", check);
    }
}
answered by user eiorgert
...