using System; class Program { static void Main() { Console.Write("Enter a number: "); int num = Convert.ToInt32(Console.ReadLine()); int smallest = 9; while (num > 0) { int digit = num % 10; if (digit < smallest) smallest = digit; num /= 10; } Console.WriteLine("Smallest digit: " + smallest); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter