We are providing online training of realtime Live project on Asp.Net MVC with Angular and Web API. For more information click here. If you have any query then drop the messase in CONTACT FORM

Wednesday, June 17, 2015

Write Program to Get a Number and Display the Sum of the Digits.

 class Program
    {
        static void Main(string[] args)
        {
            int reminder, n,sum=0;
            Console.WriteLine("Enter the number");
            n = int.Parse(Console.ReadLine());

            while(n>0)
            {
                reminder = n % 10;
                n = n / 10;
                sum = sum + reminder;
            }
            Console.WriteLine("Sum of the all given digit:{0}", sum);
            Console.ReadLine();
        }
    }
Output:


No comments: