You are on page 1of 7

Name: Hamza Javed

Roll No. 1524


#include<iostream>
using namespace std;
int main()
{
cout<<"welcome";
try
{
throw 10;
cout<<"\n In try";
}
catch( int e)
{
cout<<"\n Expression No:"<<e;
}
cout<<"\n Last line";
return 0;
}
#include<iostream>
using namespace std;
class hamza
{
public:
Error(){
int a, b;
cout<<"\n\t Enter two values a and b";
cin>>a>>b;
int x=a/(a-b);
cout<<"\n\t x="<<x;

}
};
continued

int main()
{
hamza obj;
obj.Error();

return 0;
}
#include<iostream>
using namespace std;
class hamza
{
public:
int a;
int b;
int x;
Error()
{
cout<<"\n\t Enter two values a and b";
cin>>a>>b;
x=a-b;
try
{
if(x!=0)
{
cout<<"\n\t Result:"<<a/(a-b);
}
 else
 {
 throw(x);
 }
 }
 catch(int e)
 {
 cout<<"\n\t Division by zero";
 }

 }

 };

 int main()
 {
 hamza obj;
 obj.Error();

 return 0;
 }

You might also like