hawzze

sum of the digits

May 12th, 2021
625
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. sing System;
  2.  
  3. namespace ConsoleApp7
  4. {
  5.     class Program1
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string input = Console.ReadLine();
  10.             int sum = 0;
  11.             for (int i = 0; i < input.Length; i++)
  12.             {
  13.                 int currentNumber = (int)Char.GetNumericValue(input[i]);
  14.                 sum += currentNumber;
  15.  
  16.             }
  17.             Console.WriteLine(sum);
  18.         }
  19.     }
  20. }
  21.  
RAW Paste Data