Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students also viewed these Databases questions

Question

Explain the nature of human resource management.

Answered: 1 week ago

Question

Write a note on Quality circles.

Answered: 1 week ago

Question

Describe how to measure the quality of work life.

Answered: 1 week ago