Advertisement
Guest User

PointInCircle

a guest
Mar 26th, 2014
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1. /*
  2.  * Write an expression that checks if given point
  3.  * (x,  y) is inside a circle K({0, 0}, 2).
  4.  * Examples:
  5. x       y       inside   
  6. 0       1       true   
  7. -2      0       true   
  8. -1      2       false  
  9. 1.5     -1      true   
  10. -1.5    -1.5    false  
  11. 100     -30     false  
  12. 0       0       true   
  13. 0.2     -0.8    true   
  14. 0.9     -1.93   false  
  15. 1       1.655   true
  16.  */
  17.  
  18. using System;
  19.  
  20. class PointInCircle
  21. {
  22.     static void Main()
  23.     {
  24.         double raduis = 2;
  25.  
  26.         Console.WriteLine("Enter X coordinate");
  27.         double x = double.Parse(Console.ReadLine());
  28.         Console.WriteLine("Enter Y coordinate");
  29.         double y = double.Parse(Console.ReadLine());
  30.  
  31.         double point = Math.Sqrt((x * x) + (y * y));
  32.  
  33.         Console.WriteLine(point <= raduis ?
  34.                             "The Point is IN the Circle"
  35.                             : "The Point is OUT of the Circle");
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement