using System;
namespace SumofDigits
{
class Program
{
static void Main(string[] args)
{
int num, sum = 0, r;
Console.WriteLine("Enter the number");
num = int.Parse(Console.ReadLine());
while(num != 0)
{
r = num % 10;
num = num / 10;
sum = sum + r;
}
Console.WriteLine("sum of digits : " + sum);
Console.ReadLine();
}
}
}
Post a Comment
If you have any doubt please let me know