-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFind Quadrant of the coordinate point.cpp
67 lines (55 loc) · 1.42 KB
/
Find Quadrant of the coordinate point.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
Problem statement
Write a program to accept a coordinate point in an XY coordinate system and determine in which quadrant the coordinate point lies.
Print
"1st Quadrant": if +x,+y
"2nd Quadrant": if -x,+y
"3rd Quadrant": if -x,-y
"4th Quadrant": if +x,-y
"x axis": if x,0
"y axis": if 0,y
"Origin": if 0,0
Detailed explanation ( Input/output format, Notes, Images )
Sample Input 1 :
5 100
Sample Output 1 :
1st Quadrant
Explanation of Sample Input 1:
Both x and y are positive so the point lies in 1st Quadrant.
Sample Input 2 :
0 -80
Sample Output 2 :
y axis
Explanation of Sample Input 2:
Since x is 0 the point lies in y-axis.
Sample Input 3 :
-2 40
Sample Output 3 :
2nd Quadrant
Explanation of Sample Input 3:
Since x is negative and y is positive the point lies in 2nd Quadrant.
*/
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
int x, y;
//input x & y axis
cin>>x>>y;
// Quadrant
if(x==0 && y==0){
cout<<"Origin";
} else if ((x > 0) && (y > 0)) {
cout << "1st Quadrant";
} else if ((x < 0) && (y > 0)) {
cout << "2nd Quadrant";
} else if ((x < 0) && (y < 0)) {
cout << "3rd Quadrant";
} else if((x>0)&&(y<0)){
cout << "4th Quadrant";
} else if ((x > 0) || (x < 0) && (y = 0)) {
cout << "x axis";
} else
cout << "y axis";
return 0;
}