#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; } |
|
|