// Exercise 3f from Lecture 3 // reading and counting ints using System; public class Tester { public static void Main () { int ushorts = 0, uints = 0, ulongs = 0; System.Console.WriteLine("Enter an (unsgined) integer value (q to quit):"); string str = System.Console.ReadLine(); while (str != "q") { ulong x = (ulong)Convert.ToInt64(str); if (x <= 65535) { ushorts++; } else if (x <= 4294967295U) { // suffix U uints++; } else { // suffix UL ulongs++; } str = System.Console.ReadLine(); } System.Console.WriteLine("{0} unsigned short, {1} unsigned int, {2} unsigned long values", ushorts, uints, ulongs); } }