Chapter 14: Problem 7
What is wrong with the following \(\mathrm{C}++\) code? Also, provide the correct code. double radius; try { cout << "Enter the radius: "; cin >> radius; cout << endl; if (radius < 0.0) throw radius; cout << "Area: " << 3.1416 * radius * radius << endl; } cout << "Entering the catch block." << endl; catch (double x) { cout << "Negative radius: " << x << endl; }
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.