What is Armstrong Number
An
ARMSTRONG NUMBER is a number which is made up of N digits and which is
equal to the sum of each digit raised to the Nth power.
This C# Program checks whether the entered number is an Armstrong number or not.
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace
Program
{
class Program
{
static void
Main(string[] args)
{
int num, remainder, sum = 0;
Console.Write("Enter
a number : ");
num =
int.Parse(Console.ReadLine());
for (int i =
num; i > 0; i = i / 10)
{
remainder = i
% 10;
sum = sum +
remainder*remainder*remainder;
}
if (sum == num)
{
Console.Write("Entered
number is an Armstrong number.");
}
else
Console.Write("Entered
number is not an Armstrong number.");
Console.ReadLine();
}
}
}