Answer to Question #325775 in C# for chi

Question #325775

6.3.

Write a program using string function that determines if the input word is a palindrome.

A palindrome is a word that produces the same word when it is reversed.


Sample input/output dialogue:

Enter a word: AMA

Reversed: AMA “It is a palindrome”


Enter a word: STI

Reversed: ITS “It is not a palindrome


1
Expert's answer
2022-04-10T17:45:34-0400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace C_SHARP
{
    class Program
    {
        


        static void Main(string[] args)
        {
            string word;
            //Get the word
            Console.Write("Enter a word: ");
            word = Console.ReadLine();


            string reversedWord = new string(word.Reverse().ToArray());
            
            //display reversed word
            Console.Write("Reversed: {0}", reversedWord);
            //check if word is palindrome
            if (word == reversedWord)
            {
                Console.WriteLine(" \"It is a palindrome\"");
            }
            else
            {
                Console.WriteLine(" \"It is not a palindrome\"");
            }




            Console.ReadKey();
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS