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

Good morning, This program has to be written in C not C++ and it has to match th

ID: 3633777 • Letter: G

Question

Good morning, This program has to be written in C not C++ and it has to match the trial run inputs and outputs exactly, as well as have the same function names. Truly thank you all for your help with this program as it is difficult to understand, so please comment on as much as possible. Again, thank you.

A palindrome is a word that reads the same way in both directions, e.g., radar, pop, noon. Write a program palindrome.c that prompts the user for a word (of length less than 15 characters). The program then determines whether the entered word is a palindrome. If the word is not a palindrome, the program prints it in reverse. The program should consist of three functions:

int main() prompts the user for the word, reads it, and then calls the following two functions, each with an array parameter that contains the read word.

int isPalindrome(char word[]) returns 1 if the string stored in word[] is a palindrome, and 0 otherwise. It ignores the case of the letters, for example RAdar is considered a palindrome.

void printResult(char word[], int iP) prints "A palindrome!" if iP is 1, and prints the
string in word[] in reverse if iP is 0.


Sample runs:
(~)$ a.out
Word: Kayak
A palindrome!
(~)$ a.out
Word: devil
lived
(~)$ a.out
Word: LooK
KooL
(~)$ a.out
Word: level
A palindrome!
(~)$

Explanation / Answer

please rate - thanks

message me if any problem understanding

#include<stdio.h>
#include<conio.h>
int isPalindrome(char word[]) ;
void printResult(char word[], int iP);
int main()
{char word[50];
int i,palin;
printf("Enter a word: ");
scanf("%s",&word);
palin=isPalindrome(word);
printResult(word,palin);
getch();
return 0;
}
void printResult(char word[], int iP)
{int i;
if(iP==1)
   printf("%s is a Palindrome ",word);
else
    {printf("%s is not a Palindrome reversed it is ",word);
    for(i=strlen(word)-1;i>=0;i--)
         printf("%c",word[i]);
    printf(" ");
    }
}
int isPalindrome( char word[])
{int i=0;
int y=0;
int j;
for(j=0;word[j]!='';j++);
j--;
while(word[i]==word[j]&&i<=j)           //only need to check halfway through the word
      {i++;
       j--;
       }
if(i>j)               //got halfway?
    y=1;
return y;
}

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