vojta249

Maturita_07 - soucet cifer

Mar 16th, 2022 (edited)
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.42 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Program
  4. {
  5.     internal class Program
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             Console.WriteLine("Napište číslo pro ciferný součet");
  10.             int cislo = int.Parse(Console.ReadLine());
  11.             int soucet = 0;
  12.             while (cislo > 0)
  13.             {
  14.                 soucet += (cislo % 10);
  15.                 cislo /= 10;
  16.             }
  17.  
  18.             Console.Write("Výsledkem je: ");
  19.             Console.WriteLine(soucet);
  20.             Console.ReadKey();
  21.         }
  22.     }
  23. }
Add Comment
Please, Sign In to add comment