Write a c# program to check armstrong number.

 


using System;

public class ArmstrongNumber
{
    public static void Main(string[] args)
    {
        int number, temp, digit, sum = 0;

        Console.WriteLine("Enter a number: ");
        number = int.Parse(Console.ReadLine());

        temp = number;
        while (temp > 0)
        {
            digit = temp % 10;
            sum += digit * digit * digit;
            temp /= 10;
        }

        if (number == sum)
        {
            Console.WriteLine(number + " is an Armstrong number.");
        }
        else
        {
            Console.WriteLine(number + " is not an Armstrong number.");
        }
    }
}
Write a c# program to check armstrong number. Write a c# program to check armstrong number. Reviewed by Bhaumik Patel on 9:35 PM Rating: 5