otakugirl539 otakugirl539
  • 14-09-2019
  • Computers and Technology
contestada

How can an exception be explicitly raised in C++? How are exceptions bound to handlers in C++?

Respuesta :

flightbath flightbath
  • 19-09-2019

Answer:

Exceptions are raised using throw statement in c++.

Explanation:

Try block is used to keep the statements which we felt that they will raise an exception. Catch block is used to catch the exception which is thrown by the try block.

#include<iostream.h>

void main(){

int x,y,z;

try{

cout<"enter 2 numbers";

cin>>x>>y;

if(y==0)

throw y;

z=x/y;

}

catch(int x){

cout<<"exception caught";

}

}

Answer Link

Otras preguntas

give me a sentence with the words risk and wages
Twice as number decreased by 9 is 7
Is the square root of 2 between 1.3 and 1.4? how do you know!
What would I put for the digit valuenumber 601,099 in the ten thousand place+
describe the relationship between the value of a dollar and the value of a dime
A bus on a regular schedule takes 3 1/4 hours to reach its destination. The express bus takes 2 1/2 hours to make the same trip. How much travel time can be sa
What's the verbal expression for "4(2x-7)"
describe the relationship between the value of a dollar and the value of a dime
what is the place underground where plates start to slip called.
For what reason was the "Union Party" created? Who were its candidates?