Computer Science, asked by gsubrata6885, 1 year ago

Write a c++ program where you can use multiple catch block in a single program using single try block.

Answers

Answered by Anonymous
3

void test(int x) {

   try {

       if (x > 0)

           throw x;

       else

           throw 'x';

   } catch (int x) {

       cout << "Catch a integer and that integer is:" << x;

   } catch (char x) {

       cout << "Catch a character and that character is:" << x;

   }

}

void main() {

   clrscr();

   cout << "Testing multiple catches\n:";

   test(10);

   test(0);

   getch();

}

Similar questions