0
Write a code in C++, which should take the input in the form of a, b and c from user (if user enters a = 0, then an error should
1 Réponse
0
#include <iostream>
class CustomException : std::exception {
public:
const char* what() { return "A cannot be zero"; }
};
int main()
{
int a,b,c;
std::cin >> a >> b >> c;
try {
if(a == 0) throw CustomException();
} catch(CustomException& e) {
std::cout << e.what() << std::endl;
}
// Do something else.
return 0;
}