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

Using C and start only with #include<stdio.h> int main() A palindrome is a word

ID: 3633869 • Letter: U

Question

Using C and start only with #include<stdio.h> int main()

A palindrome is a word that reads the same way in both directions, e.g., radar, pop, noon. Write a program 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 palin-drome.
_ 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.

Ex)
Word:(output) Kayak(input)
A palindrome!(output)
Word:(output) devil(input)
Lived(output)
Word:(output) LooK(input)
KooL(output)
Word:(output) level(input)
A palindrome!(output)

Explanation / Answer

//This code fills all of your requirements asked in the question

int isPalindrome(char word[]);
void printResult(char word[],int ip);
int main()
{
int palin;
char word[14];
printf(" Enter String ");
scanf("%s",word);
palin=isPalindrome(word);
printResult(word,palin);
return 0;
}
int isPalindrome(char word[])
{
int i=0,j=0,ispali=0;
for(i=0;word[i]!='';i++);
while((toupper(word[j]))==(toupper(word[i-1])))
{
j++;
i--;
ispali=1;
}
if(ispali==1)
return 1;
else
return 0;
}

void printResult(char word[],int ip)
{
if(ip==1)
printf("It is Palindrome ");
else
{
int i,len;
for(len=0;word[len]!='';len++);
printf("Reverse String ");
for(i=len-1;i>=0;i--)
printf("%c",word[i]);
}}

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

Output:

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