Armstrong :
Also known as narcissistic numbers, Armstrong numbers are the sum of their own digits to the power of the number of digits. As that is a slightly brief wording, let me give an example: 153 = 1³ + 5³ + 3³ Each digit is raised to the power three because 153 has three digits. |
SOURCE CODE :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace palindrome
{
class pali
{
public void palindrome()
{
int n, num, rev = 0, dig;
Console.WriteLine("ENTER A NUMBER...: ");
num = int.Parse(Console.ReadLine());
n = num;
while(num>0)
{
dig = num % 10;
rev = rev * 10 + dig;
num = num / 10;
}
if (n == rev)
Console.WriteLine(" GIVEN NUMBER IS A PALINDROME");
else
Console.WriteLine(" GIVEN NUMBER NOT A PALINDROME");
Console.Read();
}
}
class Program
{
static void Main(string[] args)
{
pali p = new pali();
p.palindrome();
}
}
}
OUTPUT:
ENTER A NUMBER
1231
GIVEN NUMBER NOT A PALINDROME
No comments:
Write comments