Monday 10 December 2012

Code for Palindrom String

using System;
namespace Console_Palindrom
{
    class Palindrom
    {
        public void dispPal()
        {
            string str = string.Empty;
            Console.WriteLine("Enter the string :");
            string s = Console.ReadLine();
            int i = s.Length;
            for (int j = i - 1; j >= 0; j--)
            {
                str = str + s[j];
            }
            if (str == s)
            {
                Console.WriteLine(s + " is Palindrom");
            }
            else
                Console.WriteLine(s + " is not palindrom");
            Console.WriteLine(str);
            Console.Read();
        }

        static void Main(string[] args)
        {
            Palindrom p = new Palindrom();
            p.dispPal();
            Console.ReadKey();
        }
    }
}

No comments:

Post a Comment