+ 1

c++

Rearrange the code to declare two integer variables: a and b, print to the screen the division equation a/b. If b is equal to 0, throw an exception with a 0 value. cout << a / b << endl; int a; int b; throw 0; if (b == 0) cin >> a >> b;

9th Mar 2017, 6:09 AM
Sunita Sharma
2 odpowiedzi
+ 7
for java use try-catch block... for c++ search about exception handling....
9th Mar 2017, 6:27 AM
Ronit Kumar
Ronit Kumar - avatar
+ 7
int a,b; cin>>a>>b; if(b==0) throw 0; cout<<a/b<<endl;
9th Mar 2017, 6:48 AM
Ronit Kumar
Ronit Kumar - avatar