How to print armstrong numbers by C#

Shubham
Posted by Shubham under C# category on | Points: 40 | Views : 16442
using System;
class armstonmg
{
public static void Main()
{
int num = Convert.ToInt32(Console.ReadLine());
int m = num;
int rem = 0;

int sum = 0;
while (num > 0)
{
rem = num % 10;
sum = sum + (int)Math.Pow(rem, 3);
num = num / 10;
}
if (m == sum)
{
Console.Write("Armstrong No...");
}
else
{
Console.Write("Not Armstrong No...");
}
Console.ReadLine();
}
}

Comments or Responses

Login to post response