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
Name:SWATHIKA G
Reg No:212221230113
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("{0} is Palindrome", s);
}
else
{
Console.WriteLine("{0} is not Palindrome", s);
}
}
}
}
Thus the C# program to display whether the given string is Palindrome or not is executed successfully.