0
While loop
1. Write a program that keep prompting the user to insert a point (x, y) in the Cartesian plane, then the program should find and print in which quarter the inserted point (x, y) is located. The user will stop if he inputs zero for both x and y. Note that: âQ1â: x and y are positive values. âQ2â: x is negative, while y is positive. âQ3â: x is positive, while y is negative âQ4â:. x and y are negative values. âOn linesâ: If x or y equals to zero.
1 Answer
+ 1
int x, y;
while (1 == 1) {
cin >> x;
cin >> y;
if (x == 0 && y == 0) {
cout << "On lines";
break; }
if (x > 0 && y > 0) {
cout << "Q1";
continue; }
if (x < 0 && y > 0) {
cout << "Q2";
continue; }
if (x > 0 && y < 0) {
cout << "Q3";
continue; }
if (x < 0 && y < 0) {
cout << "Q4";
continue; }
}