Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class testLoops
- {
- static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- int lastDigit = 0;
- int sumDigits = 0;
- do
- {
- lastDigit = n % 10;
- n = n / 10;
- sumDigits += lastDigit;
- } while (n != 0);
- Console.WriteLine(sumDigits);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement