C# Saved Program: serene-home

facebook share

Here's the online compiler accompanied with IDE at your service. This is a saved code by one of our users. Try it out or save your own from the IDE page and don't forget to leave a feedback. You can find that at the bottom of the page.


//This C# program will take an input string,  check whether or not a it is a palindrome
using System;
namespace palindrome
{
    class Program
    {
        static void Main(string[] args)
        {
            string s,revs="abcdcba";
            Console.WriteLine(" Enter string: ");
            s = Console.ReadLine();
            for (int i = s.Length-1; i >=0; i--) //String Reverse
            {
                revs += s[i].ToString();
            }
            if (revs == s) // Checking whether string is palindrome or not
            {
                Console.WriteLine("String is Palindrome \n Entered String Was: {0} and reverse string is: {1}", s, revs);
            }
            else
            {
                Console.WriteLine("String is not Palindrome \n Entered String Was {0} and reverse string is {1}", s, revs);
            }
        }
    }
}
Execute

Output

Press the execute button or CTRL + enter to run code.

Inputs