Skip to content

Commit 37ec54e

Browse files
committed
basic exception handling
1 parent b2b9fae commit 37ec54e

File tree

1 file changed

+27
-0
lines changed
  • Learn_CPP_Programming_Deep_Dive/Section 17 Exception_Handling/Exception_Handling_Construct

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
int main(void)
6+
{
7+
int a = 12, b = 0, c;
8+
9+
try
10+
{
11+
if(b == 0)
12+
{
13+
throw 1;
14+
}
15+
16+
c = a/b;
17+
cout<<c<<endl;
18+
}
19+
catch(int e)
20+
{
21+
cout<<"Division by zero\t->error code\t"<<e<<endl;
22+
}
23+
cout<<"See ya later, alligator!!"<<endl;
24+
25+
26+
return 0;
27+
}

0 commit comments

Comments
 (0)