The program that solves problem 2 (a) on p.275 should be named as proj4_a.c. It must include and implement the following function prototypes to solve problem 2 (a). void get_msg(char [], int *); bool palindrome(char [], int);

Respuesta :

Answer:

#include <iostream>

#include <cstring>

using namespace std;

bool isAPalindrome(char* palindrome);

int main()

{

   char palindrome[30];

   bool palindrome_check;

   cout << "Please enter an word or phrase.\n";

   cin.getline(palindrome, 30);

   palindrome_check = isAPalindrome(palindrome);

   if (palindrome_check = true)

   {

       cout << "Input is a palindrome\n";

   }

   else

   {

       cout << "Inputis not a palindrome\n;";

   }

system("pause");

return 0;

}

bool isAPalindrome(char* palindrome)

{

   char* front;  

   char* rear;  

front = palindrome;// starts at the left side of the c string

rear = (palindrome + strlen(palindrome)) - 1;//starts at the right side of the c-string. adds the c string plus the incriment value of s

while (front <= rear)

{

 if (front = rear)

 {

  front++;

  rear--;

 }

 else

 {

  return false;

 }

}

   return true;

}

ACCESS MORE