Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Division by zero exception example
// example of the throw/try/catch exception handling in C++ // try making y nonzero // try changing the exception type to int* and see what happens #include <assert.h> #include <iostream> using namespace std; int division(int a, int b) { if( b == 0 ) { throw "Division by zero condition!"; } cout << "Made it past the exception..." << endl; return (a/b); } int main () { int x = 10; int y = 0; int z; try { z = division(x, y); cout << "The answer is " << z << endl; } catch (const char* msg) { cerr << "Caught an exception! " << endl; cerr << msg << endl; } return 0; }
run
|
edit
|
history
|
help
0
11/18
First test
PrintAddress
BucketSort
Example Node Program
Program_3
Test3
tuple, order of members
Set sub sequences.
Store Information in Structure and Display it