#include <iostream.h>
#include <conio.h>
void main( )
{
int num,denum,ans;
clrscr();
cout<<”Enter two numbers\n”;
cin>>num>>denum;
try
{
If ( denum ==0)
throw(denum);
ans = num/denum;
cout<<”Ans =”<<ans<<”\n”;
}
catch(int x)
{
cout<<”Division by zero is not allowed\n”;
}
Output :
Enter two numbers
10 0
Division by zero is not allowed
#include <conio.h>
void main( )
{
int num,denum,ans;
clrscr();
cout<<”Enter two numbers\n”;
cin>>num>>denum;
try
{
If ( denum ==0)
throw(denum);
ans = num/denum;
cout<<”Ans =”<<ans<<”\n”;
}
catch(int x)
{
cout<<”Division by zero is not allowed\n”;
}
Output :
Enter two numbers
10 0
Division by zero is not allowed
0 comments:
Post a Comment