Answered step by step
Verified Expert Solution
Question
1 Approved Answer
c# A word is a palindrome if it reads the same backwards and forwards. For example, dad and otto are palindromes but hat and boat
c#
A word is a palindrome if it reads the same backwards and forwards. For example, dad and otto are palindromes but hat and boat are not. The following program attempts to find whether a word is a palindrome. The user enters the number of characters in the word, and then enters each character, using only lowercase characters. Find and correct any errors in this program.
public static void Main() { Console.Write("How mant characters? "); int size = int.Parse(Console.ReadLine()); char[] a = new char[size]; for (int i = 0; i < a.length; i++) { Console.WriteLine("Enter next character"); a[i] = int.Parse(Console.ReadLine()); } Console.Write("The Word "); for (int i = 0; i < a.length; i++) { Console.Write(a[i]); for (int i = 1; i < a.length/2; i++) { if (a[i] != a[a.Length-i]) { Console.WriteLine(" is not a palindrome"); Environment.Exit(0); } Console.WriteLine(" is a palindrome"); } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started