Answers for "try-catch exception"

3

try catch

try {
  try_statements
}
catch (exception_var) {
  catch_statements
}
finally {
  finally_statements
}
Posted by: Guest on October-07-2021
0

exception handling

#include <iostream>
#include<conio.h>
using namespace std;
int main()
{
    int a=10, b=0, c;
    // try block activates exception handling
    try 
    {
        if(b == 0)
        {
            // throw custom exception
            throw "Division by zero not possible";
            c = a/b;
        }
    }
    catch(char* ex) // catches exception
    {
        cout<<ex;
    }
    return 0;
}
Posted by: Guest on November-09-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language