This C# Program is written to Check Whether the Entered Number is an Armstrong Number or Not . An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself.
class programme
{
static void Main(string[] args)
{
int number, remainder, sum = 0;
Console.Write("Enter the
Number: ");
number = int.Parse(Console.ReadLine());
for (int i = number; i > 0; i = i / 10)
{
remainder = i % 10;
sum = sum + remainder * remainder *
remainder;
}
if (sum == number)
{
Console.Write("Entered
Number is an Armstrong Number");
}
else
Console.Write("Entered Number
is not an Armstrong Number");
Console.ReadLine();
}
}
0 comments:
Post a Comment