Demonstrate try, catch block - C++ Program
Q. Write a C++ program to demonstrate the use of try, catch block with the argument as an integer and string using multiple catch blocks.
- Exception handling means handling of abnormal or unexpected events.
- Exception handling is done by 'try', 'catch', 'throw' keywords.
- It transfers the control to special functions called Handlers and makes it easy to separate the error handling code.
Following program is demonstrating the use of try, catch block with the argument as an integer and string using multiple catch blocks.
using namespace std;
void test_try(int num)
if(num>=0 && num<=9)
cout<<"\n It is not a Single Number ";
cout<<"\n It is a Single Number";
cout<<"\n Enter Number : ";