Sunday 20 April 2014

       

Write a program in c# (c sharp) to  Check whether given number is Palindrome number or not .

using System;

namespace PalindromeNumber
{
    class Program
    {
        static void Main(string[] args)
        {   int num, rem, sum = 0, temp;
            Console.WriteLine("Enter a number: ");
            num = Convert.ToInt32(Console.ReadLine());
            temp = num;
            while (Convert.ToBoolean(num))
            {
                rem = num % 10;
                num = num / 10;
                sum = sum * 10 + rem;
            }
            Console.WriteLine("\n The Reversed Number is: {0} \n", sum);
            if (temp == sum)
            {
                Console.WriteLine("Number is Palindrome \n");
            }
            else
            {
                Console.WriteLine("Number is not a palindrome..!");
            }
            Console.ReadKey();
        }
    }
}

If anyone have any doubt about the program , please comment and you can also mail me on "ibsarmschauhan13@gmail.com" and "makansingh42@yahoo.com".

Thank you so much :)

No comments:

Post a Comment