Friday 23 January 2015

C # program to check a string is palindrome or not

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

namespace Palindrome_String
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter the String :");
            String str, revs = "";
            str = Console.ReadLine();
            for (int i = str.Length - 1; i >= 0; i--)
            {
                revs= revs+str[i].ToString();
            }
            if(revs == str)
            {
                Console.WriteLine("");
                Console.WriteLine("Entered Text is {0}",str);
                Console.WriteLine("");
                Console.WriteLine("It is a palindrome");
            }
            else
            {
                Console.WriteLine(" Entered Text is not a palindrome");
            }
            Console.ReadLine();
        }
     }
}


No comments:

Post a Comment