Tuesday, 27 November 2012

Sum of Digit

using System;
using System.Collections.Generic;
using System.Text;

namespace sum_of_digit
{
class sumofdigit
{
static void Main(string[] args)
{
int n,sum=0,m;
Console.WriteLine("\tSUM OF ALL DIGIT");
Console.WriteLine("\t****************");
Console.WriteLine("Enter the Number");
n=int.Parse(Console.ReadLine());
while(n!=0)
{
m=n%10;
sum=sum+m;
n=n/10;
}
Console.WriteLine("Sum of digit={0}",sum);

}
}
}

No comments:

Post a Comment