How to Exception handling C++ programming Example Code Question with solution
1.
What will be the output of this code?
int var=12;
try{
cout<<"Try block
Entered"<<endl;
if(var>30)
throw var;
cout<<"Try block
Leaving"<<endl;
}catch(int thrown_value){
cout<<"Exception
value:"<<thrown_value<<endl;
}
cout<<"After try
block"<<endl;
Try block Entered
Try block Leaving
After try block
|
|
2.
What will be the output of this code?
int var=50;
try{
cout<<"Try block
Entered"<<endl;
if(var>30)
throw var;
cout<<"Try block
Leaving"<<endl;
}catch(int thrown_value){
cout<<"Exception
value:"<<thrown_value<<endl;
}
cout<<"After try
block"<<endl;
Try block Entered
Exception
value:50
After try block
|
|
0 comments:
Post a Comment