fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. double side;
  6.  
  7. do {
  8. cout << "Enter the side length of the square (positive number): ";
  9. cin >> side;
  10.  
  11. if (side <=0) {
  12. cout << "Error: side must be positive.\n";
  13. }
  14.  
  15. } while (side <= 0);
  16.  
  17. double area = side * side;
  18.  
  19. cout << "the area of the square is: " << area << "\n";
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
Enter the side length of the square (positive number): the area of the square is: 0