Divide by 0
SAT
c_cpp
a year ago
352 B
5
Indexable
#include <iostream>
using namespace std;
int main() {
int num,den,res;
cout<<"enter 2 no:"<<endl;
cin>>num>>den;
try{
if(den == 0){
throw den;
}
res = num/den;
}
catch(int ex){
cout<<"0 not allowed"<<endl;
}
cout<<"div is:"<<res<<endl;
return 0;
}
Editor is loading...
Leave a Comment