- 1
Why this is not working.
#include<iostream> using namespace std; int main() { int n1,n2; cout<<"Enter first Number :"; cin>>n1; cout<<"Enter second Number :"; cin>>n2; if(n2==0){ throw 0; } cout<<"Division is :"<<n1/n2; catch (int x){ cout<<"Can't divide by zero" <<x; } return 0; }
3 Réponses
+ 5
wrap your if condition inside the try block.
+ 4
Vikalp Monas
Learn 80.1 lesson again because that's not a proper syntax of try catch.
+ 1
Please always tag the language you're asking about.
https://code.sololearn.com/W3uiji9X28C1/?ref=app