How to implement Exception Handling in C++

Rate this article
0 out of 5
In this tutorial we will show you how to implement Exception Handling in C++. After viewing the video tutorial, download the source code and try to modify the code so as to get a feel of what is learned in this video tutorial.



Program

#include <iostream.h>
#include <stdlib.h>
#include<conio.h>

//main function
int main()
{
   int I_one=50,I_two=50;
   int I_result=I_one-I_two;
   //starting try block
   try
   {
     if(I_result!=0)
     {
     cout<<"Result of division="<<(I_one/I_result);
   }
   else
   {
       throw(I_result);
   }
   }
catch(int I_var)
 {
     cout<<"Exception Caught:Division by Zero ";
   }
   getch();
return 0;
}



Source Code


Joined Date :04-Feb-2013
Articles
Posted
27
Messages
Posted
0


   
Messages
Posted:
Post Your Comments
Name (Max 50 Chars)
Comments

TekTipsDownload
GateExam
Academic Projects
TekTipsExperts



 
Site optimized for IE7, 1280 X 768 and above. Copyright © 2010 - 2018 KTS InfoTech
Site Developed Using KTS WebCloud