# include # include using namespace std; int main ( ) // // QUADRANT.CPP reads X and Y values from a user and reports // whether the point (X,Y) is in // // | // quadrant 2 | quadrant 1 // | // -----------+---------------- // | // quadrant 3 | quadrant 4 // | // { float x, y; cout << "Enter the X and Y coordinates of a point: "; cin >> x >> y; // // One way to do it. // if ( 0.0 <= x ) { if ( 0.0 <= y ) { cout << "(" << x << "," << y << ") is in quadrant 1.\n"; } else { cout << "(" << x << "," << y << ") is in quadrant 4.\n"; } } else { if ( 0.0 <= y ) { cout << "(" << x << "," << y << ") is in quadrant 2.\n"; } else { cout << "(" << x << "," << y << ") is in quadrant 3.\n"; } } // // Another way. // if ( 0.0 <= x && 0.0 <= y ) { cout << "(" << x << "," << y << ") is in quadrant 1.\n"; } else if ( x < 0.0 && 0.0 <= y ) { cout << "(" << x << "," << y << ") is in quadrant 2.\n"; } else if ( x < 0.0 && y < 0.0 ) { cout << "(" << x << "," << y << ") is in quadrant 3.\n"; } else { cout << "(" << x << "," << y << ") is in quadrant 4.\n"; } return 0; }