Prevent a division by zero using the ? 1
/* C#: The Complete Reference by Herbert Schildt Publisher: Osborne/McGraw-Hill (March 8, 2002) ISBN: 0072134852 */ // Prevent a division by zero using the ?. using System; public class NoZeroDiv { public static void Main() { int result; int i; for(i = -5; i < 6; i++) { result = i != 0 ? 100 / i : 0; if(i != 0) Console.WriteLine("100 / " + i + " is " + result); } } }