using System;
class MainClass {
public static void Main() {
int[] numer = { 4, 8, 16};
int j=0;
for(int i=0; i < 10; i++) {
try {
Console.WriteLine(numer[i] + " / " +
numer[i] + " is " +
numer[i]/j);
}
catch (DivideByZeroException) {
// catch the exception
Console.WriteLine("Can't divide by Zero!");
}
catch (IndexOutOfRangeException) {
// catch the exception
Console.WriteLine("No matching element found.");
}
}
}
}
Output
Can't divide by Zero!
Can't divide by Zero!
Can't divide by Zero!
No matching element found.
No matching element found.
No matching element found.
No matching element found.
No matching element found.
No matching element found.
No matching element found.