Hello Learner
Contributor
Stats
 Views : 177107 Comments : 2 Rating : 0
Actions

# .NET program to check the number is palindrome or not

By Ashok Nalam on 25 Dec 2012 | Category: C# | Tagged: palindrome number
In this snippet we will write a program to check whether the given number is palindrome number or not.
 Rate this resource

#### What is palindrome Number?

"Palindrome number is a number that remains the same when its digits are reversed"

Example:

Number 151 - palindrome number.
Number 152 - Not a palindrome number.

#### Program:

`class PalindromeNumberOrNot{    public static void Main()    {        Console.WriteLine("********** Palindrome Number Check Example ********");        Console.WriteLine("Enter Number to Want to check");        int numberToCheck = int.Parse(Console.ReadLine());        int lenthOfNumber = numberToCheck.ToString().Length;        double reminder = 0;        double sum = 0;        int tempNo = numberToCheck;        while (tempNo > 0)        {            reminder = tempNo % 10;            sum = sum * 10 + reminder;            tempNo = tempNo / 10;        }        if (sum == numberToCheck)        {            Console.WriteLine("The given Number {0} is a Palindrome Number", numberToCheck);        }        else        {            Console.WriteLine("The given Number {0} is NOT a Palindrome Number", numberToCheck);        }    }}`

#### output:

Input =151 (palindrome Number)

Input =152 (Not a palindrome Number)

Some of palindrome numbers are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99, 101, 111, 121, 131, 141, 151, 161.......

 Rate this resource