using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class CalcAvgPerc
{
static void Main(string[] args)
{
int number, temp, sum = 0, remainder;
Console.WriteLine("Program to add digits of a Number");
Console.WriteLine("Enter the Number for which you want to sum up the digits..");
number = int.Parse(Console.ReadLine());
Console.WriteLine("Adding the digits for Number {0} ......", number);
System.Threading.Thread.Sleep(2000);
temp = number;
while (temp != 0)
{
remainder = temp % 10;
sum = sum + remainder;
temp = temp / 10;
}
Console.WriteLine("Sum of the digits for number : {0} is Sum : {1}", number, sum);
Console.ReadKey();
}
}
}This Program to add all digits of a Number in C# language.
