Quick actions

cmd+k|ctrl+k

Navigation

Languages

exception_handling

Snippet info

Language

Cpp

Visibility

public

Author

ganesh26

Created

2020-10-14T10:39:29Z

Updated

2020-10-14T10:39:29Z

#include <iostream>
using namespace std;
float func(int x , int y)
{
    if( y == 0)
    {
        throw " exception division by zero " ;
    }
    return x/y ;
}
int main() {
    cout << "Hello World!" << endl ;
    try {
         float z = func(4,0); 
          cout << " result is " << z << endl ;
    }
    catch(char const * msg){
        
        cerr << msg << endl ;
     }
        
    
    //cout << " result is " << z << endl ;
    return 0;
}
INFO