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

The area of a triangle with a height of 9 cm and a base of 6 cm is
If organelles were not functioning properly, which of the following would be true? A. Both unicellular and multicellular organisms would not be able to carry ou
Find the simple interest. $1,540, 8.25%, 2 years
How did the battle of Gettysburg affect the course of American history Will give brainlist
Parts of speech,words and basic phrase
What is abortion and how does the process work. How much money does abortion usually cost.
What is the measure of angle Z
In Hackensack High School, the ratio of students to teachers is 9 to 2. If there are 90 teachers at the High School, how many students are there?
Find the measure of arc ABC.
In the 1990's about 75% of high school graduates attended college. A survey of 2,000 high school graduates was taken in 2018 that showed 1,453 attended college.