quadrant please

ok

i have a question that ask user to insert 2 digit (X and Y)

then base on user number, it will give an out put if its on quadrant,1,2,3 or 4

this is the code im using

#include <iostream>
using namespace std;

int main (void) {

/* declarations */
int x_coordinate = 0, y_coordinate = 0;

/* Prompt user to enter x-coordinate value */
cout << "Please enter the x-coordinate: ";
cin >> x_coordinate;

/* Prompt user to enter y-coordinate value */
cout << "Please enter the y-coordinate: ";
cin >> y_coordinate;

/* check for point on x-axis */
if(y_coordinate == 0)
{
cout << "(" << x_coordinate << "," << y_coordinate << ") is on the x-axis.";
}

/* check for point on y-axis */
if(x_coordinate == 0)
{
cout << "(" << x_coordinate << "," << y_coordinate << ")is on the y axis";
}

/* check for quadrant I */
else if(x_coordinate > 0 && y_coordinate > 0){
cout <<"("<<x_coordinate <<","<< y_coordinate <<")is in quadrant I";
}

/* check for quadrant II */
else if(x_coordinate < 0 && y_coordinate > 0){
cout<<"("<<x_coordinate <<","<< y_coordinate <<")is in quadrant II";
}

/* check for quadrant III */
else if(x_coordinate < 0 && y_coordinate < 0){
cout<<"("<<x_coordinate <<","<< y_coordinate <<")is in quadrant III";
}

/* check for quadrant IV */
else{
cout<<"("<<x_coordinate <<","<<y_coordinate <<")is in quadrant IV";
}

/* all possibilities covered by now */

/* terminate successfully */
return 0;
}



but i have some bug here, where when i insert 0, 0 on the program its come out

cout << "(" << x_coordinate << "," << y_coordinate << ") is on the x-axis
and
cout << "(" << x_coordinate << "," << y_coordinate << ") is on the y axis

to gather

how can i make it if user insert 0,0
the out put will be "is the origin"

Simply put both conditions in a single if.
if i put both conditions in a single if, if user insert number 0,2 or 2,0

i can not get out put like currently im getting it..

i mean this out put

cout << "(" << x_coordinate << "," << y_coordinate << ") is on the x-axis
and
cout << "(" << x_coordinate << "," << y_coordinate << ") is on the y axis
if (a && b){
//...
}else if (a){
//...
}else if (b){
//...
}else if //...
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
#include <iostream>
using namespace std;

int main (void) {

    /* declarations */
    int x_coordinate = 0, y_coordinate = 0;

    /* Prompt user to enter x-coordinate value */
    cout << "Please enter the x-coordinate: ";
    cin >> x_coordinate;

    /* Prompt user to enter y-coordinate value */
    cout << "Please enter the y-coordinate: ";
    cin >> y_coordinate;

    
	/* check for point on origin */
	if (x_coordinate == 0&& y_coordinate == 0)
	{	
		cout << "(" << x_coordinate << "," << y_coordinate << ") is the origin." << "\n";
	}

	/* check for point on x-axis */
    else if(y_coordinate == 0)
	{
		cout << "(" << x_coordinate << "," << y_coordinate << ") is on the x-axis." << "\n";
    }

    /* check for point on y-axis */
    else if(x_coordinate == 0)
	{
        cout << "(" << x_coordinate << "," << y_coordinate << ")is on the y axis" <<"\n";
    }

    /* check for quadrant I */
    else if(x_coordinate > 0 && y_coordinate > 0){
        cout <<"("<<x_coordinate <<","<< y_coordinate <<")is in quadrant I" <<"\n";
    }

    /* check for quadrant II */
    else if(x_coordinate < 0 && y_coordinate > 0){
        cout<<"("<<x_coordinate <<","<< y_coordinate <<")is in quadrant II" <<"\n";
    }

    /* check for quadrant III */
    else if(x_coordinate < 0 && y_coordinate < 0){
        cout<<"("<<x_coordinate <<","<< y_coordinate <<")is in quadrant III" <<"\n";
    }

    /* check for quadrant IV */
    else{
        cout<<"("<<x_coordinate <<","<<y_coordinate <<")is in quadrant IV" <<"\n";
    }

    /* all possibilities covered by now */

    /* terminate successfully */
    return 0;
} 


ok, i have done this, please tell me if there is a bug or anything, i have tested it, and there is no bug for me..
Looks fine.
Thanks firedraco :)
Topic archived. No new replies allowed.