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.

7th Dec 2017, 7:45 PM
Reema Jarar
Reema Jarar - avatar
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; } }
7th Dec 2017, 8:35 PM
🐙evil octopus
🐙evil octopus - avatar