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

Urgent need of a C program that will check a user inputted stringand determine w

ID: 3617709 • Letter: U

Question

Urgent need of a C program that will check a user inputted stringand determine whether or not it is a palindrome (the same forwardas it is backword (i.e. racecar, abba))

--------------------------

Working it out a bit and have gotten the program to compile andrun. The only flaw is that it ALWAYS returns the result "Not aPalindrome"

UPDATED CODE:


#include <stdio.h>
#include <string.h>
#include <ctype.h>



// This function determines if a string is a palindrome.

int is_palindrome(char* message)
{
    char *p,*q;
    p=q=message;

    while(*q!='')
    q++; // q represents the null character.
    q--;//q represents the last character ofstring.

    while(p<q)
    {
        if(*p!=*q)
    return(0);

    p++;
    q--;
    }

    return(1);

}


int main(void)
{
    char input[1000] = "";
  
    printf ("Enter a message: ");

    fgets(input, 1000, stdin);
    input[999] = 0;

    if (is_palindrome(input))
    {
        printf("Palindrome ");
    }
  
    else
    {
        printf ("Not apalindrome ");
    }
  
    getchar(); // Hold window open.
    getchar();
    return 0;
}

Thanks so much

Explanation / Answer

please rate - thanks #include #include #include // This function determines if a string is a palindrome. int is_palindrome(char* message) {     char *p,*q;     p=q=message;     while(*q!='')             q++; // q represents the null character.     q-=2;//q represents the last character ofstring.     while(!isalpha(*p))            p++; while(!isalpha(*q))            q--; while(tolower(*p)==tolower(*q)&&p
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