Tuesday, 27 November 2012

Armstrong No Checking

using System;
using System.Collections.Generic;
using System.Text;

namespace armstrong
{
class Program
{
static void Main(string[] args)
{
int n, r, sum = 0;
Console.WriteLine("Entre the no to check");
n = int.Parse(Console.ReadLine());
int n1 = n;
while (n != 0)
{
r = n % 10;
sum = sum + (r * r * r);
n = n / 10;
}
if (sum == n1)
{
Console.WriteLine("the given no {0} is Armstrong no",n1);
}
else
{
Console.WriteLine("the Given no {0} is not an Armstrong No",n1);
}
}
}
}

No comments:

Post a Comment