By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,791 Members | 1,196 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,791 IT Pros & Developers. It's quick & easy.

how to find if a point lies within a square

P: 1
my question ask to n in_out(xs,ys,side) that takes three numbers as input, where
side is non-negative. Here xs and ys represent the x and y coordinates of the bottom
left corner of a square; and side represents the length of the side of the square.
(Notice that xs, ys, and side completely define a square and its position in the plane).
Your function should first prompt the user to enter two numbers that represent the x
and y coordinates of some query point. Your function should print True if the given
query point is inside of the given square, otherwise it should print False. A point on the
boundary of a square is considered to be inside the square
Sep 24 '17 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 10K+
P: 12,405
If you have the coordinates of the bottom left corner and the length of the sides, then all you need to do is check that the user inputted x is between the left and right side x's and the y is between the top and bottom y's.

What have you tried to far?
Sep 25 '17 #2

Post your reply

Sign in to post your reply or Sign up for a free account.