Program to do digit summation

Niladri.Biswas
Posted by Niladri.Biswas under C# category on | Points: 40 | Views : 752
Consider a number 2345. If I add digits of 2345 then I will get 14. How to do this?

int N = 2345;
var sum = 0;
while (N != 0)
{
sum = sum + (N % 10);
N = N / 10;
}

Comments or Responses

Login to post response