Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Problem Name_single_digi
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { //Your code goes here //Console.WriteLine("Hello, world!"); // the prog is incomplete for 9223 it will return 16. int num, result; Console.WriteLine("Enter the Number : "); num = int.Parse(Console.ReadLine()); result = sum(num); Console.WriteLine("Sum of Digits in {0} is {1}", num, result); Console.ReadLine(); } public static int sum(int num) { if (num != 0) { return (num % 10 + sum(num / 10)); } else { return 0; } } } }
run
|
edit
|
history
|
help
0
Random Number Generation
uniqueness 2.8
My world
hello,world
Out reference example
ByRef
sss0
Lesson 1.2 Part I
1
Insert m into n