Program to illustrate the throwing and catching of an exception.

#include<iostream>
#define DivisionByZero 1
using namespace std;
int main()
{
int x=5,y=0;
try
{
if(y==0)
{throw DivisionByZero;}
int z=x/y;
}
catch (int exception_number)
{
if (exception_number==DivisionByZero)
{cout<<"Division By Zero is not allowed!!"<<endl;}
}
cout<<"/*\nName-Sanjampreet Singh\nRoll Number-1507967\n*/";
}

Output:

Comments

Popular posts from this blog

Program to illustrate the concept of templates.

To create an html file to implement the concept of margin, padding using cascading style sheets.

To configure the IP address for a computer connected to LAN