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

Requirements: Prompt the user for a sentence. Determine if the sentence is a pal

ID: 3656961 • Letter: R

Question

Requirements: Prompt the user for a sentence. Determine if the sentence is a palindrome -if it is, output to the screen "It is a palindrome." -if it is not, output to the screen "It is not a palindrome." Continue to prompt the user for input until the user enters "Done" (without the quotes). If the user enters "Done" then exit the program.

Question: A String is a palindrome if it can be read forward and backward with the same meaning. Capitalization and spacing are ignored. for example, "anna" and "go dog" are palindromes. write a function that accept a string and returns true if the string is a palindrome and false if its not. Test your function with the following two palindromes and at least one case that is not a palindrome

This is what I have so far:

Explanation / Answer

please rate - thanks


#include<stdio.h>
#include<string.h>
#include <conio.h>
#define ALPHA "abcdefghijklmnopqrstuvwxy"

int main(void)
{

   char pd[1000];
   int charCount;
   int x,i,j;
   char packedString[1000];
   charCount = 0;
   printf("Enter a string: ");
   gets(pd);
   while(strcmp(pd,"Done")!=0)
   {
   printf("string as entered: %s ", pd);
   for(x=0; x < sizeof(pd); x++)
   {
     pd[x] = tolower(pd[x]);
   }
   printf("string after all lower: %s ", pd);
   *packedString = '';
   char* pStr = pd;
   while(*pStr != '')
   {
    charCount = strspn(pStr, ALPHA);
    pStr[charCount] = '';
    strncat(packedString, pStr, 1000-strlen(packedString));
    pStr += charCount +1;
    printf("string after packed:%s ", packedString);
   }
j=strlen(packedString)-1;
i=0;
while(packedString[i]==packedString[j]&&i<=j)
      {i++;
       j--;
       }
if(i>j)
    printf("palindrone ");
else
   printf("not palindrone ");
printf("Enter a string: ");
   gets(pd);

}
getch();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote