Definition
A palindrome is a word or sentence that reads the same forward as it does backward.
Source Code:
string str, rever = "";
int length;
Console.WriteLine("Enter String to check for Palindrom: ");
str = Console.ReadLine();
for (length = str.Length - 1; length >= 0; length--)
{
rever = rever + str[length];
}
Console.WriteLine(rever.ToString());
Console.ReadLine();
if (rever.ToString() == str.ToString())
{
Console.WriteLine("String is a Palindrom");
Console.ReadLine();
}
else
{
Console.WriteLine("String is not a Palindrom");
Console.ReadLine();
}
Output:
A palindrome is a word or sentence that reads the same forward as it does backward.
Source Code:
string str, rever = "";
int length;
Console.WriteLine("Enter String to check for Palindrom: ");
str = Console.ReadLine();
for (length = str.Length - 1; length >= 0; length--)
{
rever = rever + str[length];
}
Console.WriteLine(rever.ToString());
Console.ReadLine();
if (rever.ToString() == str.ToString())
{
Console.WriteLine("String is a Palindrom");
Console.ReadLine();
}
else
{
Console.WriteLine("String is not a Palindrom");
Console.ReadLine();
}
Output:
Comments
Post a Comment