1

when I compiled the below code with Devc++ or Code blocks(compiler:GNU) , it does not catch the exception, and program crashes. please spmebody can help me? Thanks in advance.

#include <iostream>

using namespace std;

int main()
{
    int top = 90;
    int bottom = 0;
 try
     {
 cout << "top / 2 = " << (top/ 2) << endl;

cout << "top divided by bottom = ";
 cout << (top / bottom) << endl;

 cout << "top / 3 = " << (top/ 3) << endl;
 }
 catch(...)
 {
 cout << "something has gone wrong!" << endl;
 }

 cout << "Done." << endl;
 return 0;
    cout << "Hello world!" << endl;
    return 0;
}
Mahesh
  • 34,573
  • 20
  • 89
  • 115
eral
  • 123
  • 1
  • 16

0 Answers0