Inactive Tutor answered 10/30/20
what was your error message? the input.Length will be out of bounds. It should start with input.length-1. If you send the error message, it will be easier to find the error.
Lily P.
asked 10/30/20static bool Palindrome (string input)
{
bool pal;
string check = "";
for (int i = input.Length; i >= 0; i--)
{
check = check + input[i];
}
if(check == input)
{
pal = true;
}
else
{
pal = false;
}
return pal;
}
static void Main(string[] args)
{
Console.Write("Write a word: ");
bool palindrome = Palindrome(Console.ReadLine());
if (palindrome == true)
{
Console.WriteLine("Palindrome");
}
else
{
Console.WriteLine("Not palindrome");
}
Console.ReadKey();
Inactive Tutor answered 10/30/20
what was your error message? the input.Length will be out of bounds. It should start with input.length-1. If you send the error message, it will be easier to find the error.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.