01: #include <iostream>
02: #include <cmath>
03: using namespace std;
04:
05: int main()
06: { double area;
07: cout << "Please enter the area of a square: ";
08: cin >> area;
09: if (area < 0)
10: { cout << "Error: Negative area.\n";
11: return 1;
12: }
13:
14: /* now we know that area is >= 0 */
15: double length = sqrt(area);
16: cout << "The side length of the square is "
17: << length << "\n";
18:
19: return 0;
20: }