Challenge 10

Description

The purpose of this challenge is to manually manipulate character arrays. This challenge validates if a given word is a palindrome.

Requirements

  1. Write a program to determine if a string is a palindrome. A palindrome is a word that reads the same forwards as well as backwards. For example, madam
  2. Create a function bool is_palindrome(char  word[]). The function returns a boolean. This function performs a case-sensitive check. Madam is not a palindrome, but madam is. Do not use cout to display your result in this function.
  3. Declare a char array to hold a maximum of 50 characters.
  4. Ask the user to enter a string. Use cin.getline(char_variable, 50) function call to get the string from the user
  5. Display a message indicating if the entered string is indeed a palindrome

Sample main()

int main()
{
  char word[50];

  cout << "Enter a string: ";
  cin.getline(word, 50);

  cout << word;
  if (is_palindrome(word))
  {
    cout << " is a palindrome" << endl;
  }
  else
  {
    cout << " is not a palindrome" << endl;
  }
}

Sample Interaction / Output

Enter a string: madam
madam is a palindrome

Enter a string: taco
taco is not a palindrome

LEGEND
PROGRAM OUTPUT
USER INPUT
FROM INPUT

CATALOG ID: CPP-CHAL0010

Print Requirements