Here is an example program that demonstrates the use of try and catch block to handle an exception:#include <iostream>#include <string>using namespace std;void divide(int a, int b) { if (b == 0) { throw "Divide by zero exception"; } cout << "a/b = " << a/b << endl;}int main() { int a, b; cout << "Enter two numbers: "; ...
Showing posts with label Write a program containing a possible exception. Use a try block to throw it and a catch block to handle it properly.. Show all posts
Showing posts with label Write a program containing a possible exception. Use a try block to throw it and a catch block to handle it properly.. Show all posts