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 | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
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

8th Sep 2016, 5:15 PM
rehan altaf
rehan altaf - avatar
1 ответ
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; }
10th Sep 2016, 1:34 PM
trickybear