int main()
{
int x;
cout<<”Enter value of x : ”;
cin>>x;
try
{
if(x==1)
throw(20);
if(x==2)
throw(‘A’);
if(x==3)
throw(2.5f);
}
catch(int p)
{
cout<<”int value x=”< }
catch(char c)
{
cout<<”char value x= “<
catch(float f)
{
cout<<”float value x= “<
return 0;
}
OUTPUT:
[itlab@localhost itlab]$ g++ -o mulexc mulexc.cpp
in file included from
/usr/include/c++/3.2.2/backward/iostream.h:31;
from mulexc.cpp:1:
/usr/include/c++/3.2.2/backward/backward_warning,h:32:2:
warning:# warning this
file includes atleast one deprecated or antiquated header.
Please consider using one of the 32 headers found in section 17.4.1.2 of the c++ standard examples
Include substituting the
[itlab@localhost itlab]$ ./mulexc
Enter value of x : 1
int value x=20
[itlab@localhost itlab]$ ./mulexc
Enter value of x : 2
char value x=A
[itlab@localhost itlab]$ ./mulexc
Enter value of x : 3
float value x=2.5
[itlab@localhost itlab]$
No comments:
Post a Comment