Answers for "c# code to find sum of digits of a number"

C#
6

sum of digits in c#

int num = 123;
int sum = 0;
while(num > 0)
{
  sum += number % 10;
  num /= 10;
}
Console.WriteLine(sum); // output: 6
Posted by: Guest on April-26-2020
0

sum of digit of number c#

int result = 17463.ToString().Sum(c => Convert.ToInt32(c));
Posted by: Guest on January-04-2022

Code answers related to "c# code to find sum of digits of a number"

C# Answers by Framework

Browse Popular Code Answers by Language