Palindrome for beginners c#

Sakthi.Singaravel
Posted by Sakthi.Singaravel under C# category on | Points: 40 | Views : 1363
class Program
{
static void Main(string[] args)
{
string s1;
int j = 0;
int i = 0;
Console.WriteLine(" Enter the Input : ");
s1 = Console.ReadLine();
j = s1.Length;
while (i != (j - 1))
{
if (s1[i] == s1[j - 1])
{
i++;
j = j - 1;
}
else
{
Console.WriteLine(s1 + " is MOT palindrome");
break;
}
}
if (i == (j-1))
{
Console.WriteLine(s1 + " is a plaindrome");
}
}
}

Comments or Responses

Login to post response