C# Program to check given number is palindrome number or not - C# Program

c# Program to check given number is palindrome number or not

A palindrome number is a number that is same after reverse. For example 545, 171 are the palindrome

using System;

namespace PalindromeNumberApp
{
    class Program
    {
        static void Main(string[] args)
        {
            int num, n, rev_no=0,r;
            Console.WriteLine("Enter the number :");
            num = Convert.ToInt32(Console.ReadLine());
            n = num;
            while(n!=0)
            {
                r = n % 10;
                rev_no = rev_no*10+r;
                n = n / 10;
            }
            if (num == rev_no)
                Console.WriteLine("Given number {0} is palindrome number", num);
            else
                Console.WriteLine("Given number {0} is not a palindrome number", num);

            Console.ReadKey();
        }
    }
}

Output - C# Program to Check Whether a Number is Palindrome or Not

Enter the Number : 141   
Given number 141 is palindrome number

Enter the Number : 142
Given number 241 is not a palindrome number

C# Program to Check Whether a Number is Palindrome or Not