Find the Armstrong Number from enter by the user in C# program

Find the Armstrong Number from enter by the user in C# program

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SnEarmtrng
{
    class Program
    {
        static void Main(string[] args)
        {
            int start, end, i, d;
            int temp, sum = 0;
            Console.WriteLine("ENter start num:");
            start = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("ENter end num:");
            end = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("arm num are:");
            for (i = start; i <= end; i++)
            {
                temp = i;
                sum = 0;
                do
                {
                    d = temp % 10;
                    sum = sum + d * d * d;
                    temp = temp / 10;
                }
                while (temp != 0);
                if (i == sum)
               
                    Console.WriteLine(" " + i);
                }
           
        }
    }
Input :  Enter start number : 1
             Enter End number : 2
OutPut : 

 
 

 

Previous
Next Post »