Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _09.SumDigits
- {
- class SumDigits
- {
- static void Main(string[] args)
- {
- var n = int.Parse(Console.ReadLine());
- var sum = 0;
- do
- {
- sum = sum + (n % 10);
- n = n / 10;
- }
- while (n > 0);
- Console.WriteLine($"Sum of digits: {sum}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement