Teo_Yanchev

SumOfDigits№2 - C# - Fundamentals

Aug 19th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _02.SumofDigits2
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string num = Console.ReadLine();
  10. int sum = 0;
  11.  
  12. for (int i = 0; i < num.Length; i++)
  13. {
  14. sum += int.Parse(num[i].ToString());
  15. }
  16. Console.WriteLine(sum);
  17. }
  18. }
  19. }
  20.  
Advertisement
Add Comment
Please, Sign In to add comment