Friday, 1 September 2017

c# Program to check whether a number is palindrome or not

Simple C# Program example to check Given number is palindrome or not?

Program

using System;     
class Program
    {
        static void Main(string[] args)
        {
            int num, n, s = 0,a;
            Console.WriteLine("Enter the Number:");
            num = Convert.ToInt32(Console.ReadLine());             
            a = num;
            while (num != 0)
            {
                n = num % 10;               
 s = n + (s * 10);
                num = num / 10;
            }
            Console.WriteLine("Reverse Number : {0}", s);           
 if (s == a)
            {
                Console.WriteLine("Palindrome");
            }            
else
            {
                Console.WriteLine("Not Palindrome");
            }
        }

    }  

Output


0 comments:

Post a Comment