Showing posts with label check Number is Palindrome or not. Show all posts
Showing posts with label check Number is Palindrome or not. Show all posts

Monday, April 18, 2016

Check the Number is Palindrome or not


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

namespace ConsoleApplication8
{
    class Program
    {
        static void Main(string[] args)
        {
            int num, rev, sum = 0, temp;
            Console.Write("Enter the number");
            num = Convert.ToInt32(Console.ReadLine());
            temp = num;
            while (num != 0)
            {
                rev = num % 10;
                num = num / 10;
                sum = sum * 10 + rev;
            }
            if (temp == sum)
            {
                Console.WriteLine("Number is palindrome");
            }
            else
            {
                Console.WriteLine("Number is not palindrome");
            }
            Console.ReadLine();
        }
    }
}