using System;
namespace Prg2ConsoleApplication9
{
class ArmstrongNumber
{
static void Main(string[] args)
{
number num = new number();
num.getdata();
}
}
class number
{
public void getdata()
{
int no,r,sum=0,n=0;
Console.WriteLine("Enter number\n");
no = Int32.Parse(Console.ReadLine());
n = no;
while (n > 0)
{
r = n % 10;
n = n / 10;
sum += r*r*r;
}
if (sum == no)
{
Console.WriteLine("{0} is a Amstrong number" , no);
}
else
{
Console.WriteLine("{0} is not a Amstrong number", no);
}
Console.ReadLine();
}
}
}
If you want to add any additional points or if you find any discrepancies in this article please let me know in the comment section.
If you find this article kindly share it.
Happy programming!
Comments
Post a Comment