Program for check that given string is palindrome or not.

Hello,
Below program is for check whether given string is palindrome or not.means that string that you have provide and reverse of that string should match.
Hope you will enjoy it.

 //check given string is palindrome or not.
    class Program
    {
        static void Main(string[] args)
        {
            string s = "";
            Console.WriteLine("Enter string");
            s = Console.ReadLine();
            string final = "";
            for (int i = s.Count()-1; i >= 0; i--)
            {
               final += s[i];
            }
            if (final == s)
            {
                Console.WriteLine("Given string is palindrome");
                Console.Write(final);
            }
            else
            {
                Console.WriteLine("Given string is not palindrome");
                Console.Write(final);

            }
            Console.ReadLine();
        }
    }

   if input="madam"
   output:"Given string is palindrome".

No comments:

Post a Comment

Please let me know if you have any feedback or doubts.

Jagged Array

What is Jagged Array? Jagged array is called as "array of arrays". when you need a data inside your array element at that time you...