Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Sum of digit using recursion
//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) { int num, result; pro pg = new pro(); Console.WriteLine("Enter the Number : "); num=int.Parse(Console.ReadLine()); result =pg.sum(num); Console.WriteLine("Sum of Digits in {0} is {1}", num, result); Console.ReadLine(); } } class pro { public int sum(int num) { if (num != 0) { return (num % 10 + sum(num / 10)); } else { return 0; } } } }
run
|
edit
|
history
|
help
1
Kumaran-RegText-CityStatePostalCode Parsing
seconds to minutes, hour and seconds
iMacPro
Generics
Z_non_pow
Determine if a string has all unique characters.
Intuit // C# // listing_4.4 (StreamReader // output.txt + Convert/Parse)
MergeSort
WindowsFormsApp1
30272 Program Ex5_1 if else_2