To write a C# program to find whether the given string is a Palindrome or not.
Start
Create a class and declare two variable with string datatype
Loop over the entire string and reverse it
Use if condition to check whether the string and the reversed string is equal or not
print palindrome if it's equal else print not a palindrome.
stop
using System;
namespace palindrome
{
class Program
{
static void Main(string[] args)
{
string s, revs = "";
Console.WriteLine(" Enter string");
s = Console.ReadLine();
s=s.ToLower();
for (int i = s.Length - 1; i >= 0; i--)
{
revs += s[i];
}
if (revs == s)
{
Console.WriteLine("String is Palindrome");
}
else
{
Console.WriteLine("String is not Palindrome");
}
}
}
}
Thus the C# program to display whether the given string is Palindrome or not is executed successfully.