sum of digits of a number

PHOTO EMBED

Sun Oct 12 2025 17:08:20 GMT+0000 (Coordinated Universal Time)

Saved by @final

using System;
class Program {
    static void Main() {
        Console.Write("Enter a number: ");
        int n = int.Parse(Console.ReadLine()), sum = 0;
        while(n > 0) {
            sum += n % 10;
            n /= 10;
        }
        Console.WriteLine("Sum: " + sum);
    }
}
content_copyCOPY