4. Develop a C# program to demonstrate Division by Zero and Index Out of Range exceptions.
using System;
public class Divide
{
public static void Main(string[] args)
{
try
{
int result = 15 / int.Parse("0");
System.Console.WriteLine(result);
}
catch (DivideByZeroException e)
{
System.Console.WriteLine(e.Message);
System.Console.ReadLine();
}
}
}
OUTPUT:
****************OUTPUT1****************
Attempted to divide by zero.
****************OUTPUT2****************
15