Sum of Digits

PHOTO EMBED

Sun Oct 12 2025 13:33:31 GMT+0000 (Coordinated Universal Time)

Saved by @vplab2025 #c#

class Program
{
    static void Main()
    {
        Console.WriteLine("Enter a Number: ");
        int num = Convert.ToInt32(Console.ReadLine());

        int sum = 0;

        while (num > 0)
        {
            int digit = num % 10;
            sum += digit;
            num /= 10;
        }

        Console.WriteLine("Sum of digits: " + sum);

    }
}
content_copyCOPY