using System; class CountOddDigits { static void Main() { Console.Write("Enter a number: "); int num = Convert.ToInt32(Console.ReadLine()); int count = 0; while (num > 0) { int digit = num % 10; if (digit % 2 != 0) count++; num /= 10; } Console.WriteLine("Count of odd digits: " + count); } }
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