Quadrant Finder - Problem
Given two coordinates x and y, determine which quadrant the point lies in, or if it's on an axis.
Quadrant Rules:
- Quadrant I: x > 0 and y > 0
- Quadrant II: x < 0 and y > 0
- Quadrant III: x < 0 and y < 0
- Quadrant IV: x > 0 and y < 0
- On Axis: x = 0 or y = 0
Return the quadrant number (1, 2, 3, or 4) or the string "On Axis" if the point lies on an axis.
Input & Output
Example 1 — Quadrant IV
$
Input:
x = 3, y = -2
›
Output:
4
💡 Note:
Point (3, -2) has x > 0 and y < 0, which places it in Quadrant IV
Example 2 — Quadrant II
$
Input:
x = -5, y = 7
›
Output:
2
💡 Note:
Point (-5, 7) has x < 0 and y > 0, which places it in Quadrant II
Example 3 — On Axis
$
Input:
x = 0, y = 5
›
Output:
On Axis
💡 Note:
Point (0, 5) lies on the y-axis since x = 0
Constraints
- -109 ≤ x ≤ 109
- -109 ≤ y ≤ 109
Visualization
Tap to expand
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code