Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Develop a program that includes a function which has been created by you. This f

ID: 3530352 • Letter: D

Question

Develop a program that includes a function which has been created by you. This function should receive a single string as a parameter and decide if the string is indeed a palindrome or not a palindrome. You should make two versions of the function (each name should be distinct). The first should be a case sensitive version. The second version of the function should not be case sensitive and should also ignore spaces in the matching process. In addition to the two functions, you will need to create a main() function which prompts the user for a string and then calls each of the functions you created to test the string. The functions should each return 1 (one) if the string is a palindrome and 0 (zero) if not. You should then print an appropriate message in main() after evaluating the return from each function. Please distinguish the answers from the two functions separately in your output. Your main() should include appropriate comments as well. note: you may not use strrev since it is not included in string.h.

Explanation / Answer

#include <iostream.h>
#include <conio.h>

void main
{ char x[100];
char y[100];
int temp1,temp2;
int ans = 0;
cout << "Enter the word ";
cin >> x;
cout << "Enter the word ";
cin >> y;
temp1 = strlen(x);
temp2 = strlen(y);
for(int k = 0;k < temp1 ;k--)
{for(int j = temp2;j <= ......;j--)
{if(x[k] == j[k])
ans = 1;
continue;
else
ans = 0;
}}
if(ans == 1)
cout << "The string is palindromic";
else
cout << "The string is not palindromic";
getch();
}