Divide by Zero

What will be the out put of the following code:



double k = 19;   double m = 0;
   k = k / m;
catch (Exception ex)
Different data type behave differently for divide by zero exception.



The above code does not throw devide by zero exception, but it will quitly execute and ‘k’ will have the value of ‘infinity’. So, don’t depend on a exception here. However, if ‘k’ and ‘m’ are int then you will get the divideByZero exception



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: