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

A palindrome is a string that reads the same both forward and backward. For exam

ID: 3684009 • Letter: A

Question

A palindrome is a string that reads the same both forward and backward. For example, "tacocat" and "C" are palindromes, "cat" is not. Write a function isPalindrome that takes a string as parameter and returns 1 if the string is a palindrome and 0 otherwise. Your function must take char *str as a parameter. You should not input the length of the string as a second parameter. The end of the string should be detected as the character *. Write another function is PalindromcFlexible to test if a string is a palindrome ignoring blanks and case mismatch in the matching process. Under these rules, "Anna", "Ott o" are palindromes. Write a program pal.c to test both functions you wrote. Your program should initialize the strings listed in the table below and run is Palindrome and isPalindromeFlexible on each of them. Your program should fill and print the following table, listing each string and the result of the functions on it: (represents a space)

Explanation / Answer

#include <stdio.h>

#include <conio.h>

void main() {

char *a;

int i,len,flag=0;

clrscr();

printf(" ENTER A STRING: ");

gets(a);

len=strlen(a);

for (i=0;i<len;i++) {

if(a[i]==a[len-i-1])

flag=flag+1;

}

if(flag==len)

printf(" THE STRING IS PALINDROM"); else

printf(" THE STRING IS NOT PALINDROM");

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