5.24
#include <iostream>
#include <stdexcept>
using namespace std;
int main()
{
double a, b;
cin >> a >> b;
if (b == 0) {
throw runtime_error("Divisor Can't be zero");
}
cout << a / b << endl;
}
5.25
#include <iostream>
#include <stdexcept>
using namespace std;
int main()
{
double a, b;
while (cin >> a >> b) {
try {
if (b == 0) {
throw runtime_error("Divisor Can't be zero");
}
cout << a / b << endl;
}
catch (runtime_error error) {
cout << error.what() << '\n' << "Try Again?\nEnter y Or n" << endl;
char c;
cin >> c;
if (!cin || c == 'n') {
break;
}
}
}
}