Divide by zero exception

Dividing by zero value generates the DivideByZeroException.


using System;

class Program
{
    static void Main(string[] args)
    {
        int i = 4;
        int y = 0;
        
        int result = i / y;
        Console.WriteLine("result="+result);


    }
}

The output:


C:\g>Program.exe

Unhandled Exception: System.DivideByZeroException: Attempted to divide by zero.
   at Program.Main(String[] args)
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.