#include <iostream>
using namespace std;
int main()
{
int n;
cout<<"enter (-1,0,1):";
cin>>n;
try
{
if(n==0)
{
throw "zero";
}
else if(n==-1)
{
throw n;
}
else
throw (float)n;
}
catch(const char *msg)
{
cout<<msg;
}
catch(int n)
{
cout<<n<<"is negative";
}
catch(...)
{
cout<<"no specific";
}
}
using namespace std;
int main()
{
int n;
cout<<"enter (-1,0,1):";
cin>>n;
try
{
if(n==0)
{
throw "zero";
}
else if(n==-1)
{
throw n;
}
else
throw (float)n;
}
catch(const char *msg)
{
cout<<msg;
}
catch(int n)
{
cout<<n<<"is negative";
}
catch(...)
{
cout<<"no specific";
}
}
0 comments: