Palindromes
A palindrome is a word or phrase that reads the same backwards and forwards, ignoring punctuation, spaces, and anything that isn’t a letter.
Examples of Palindromes
Madam, I’m Adam.
Kayak
Racecar
A man, a plan, a canal – Panama!
Able was I, ere I saw Elba.
C Program ONLY (Please not C++ or Java)
I need to write a program that does the following: *USING STRINGS TO PERFORM THE FOLLOWING*:
1. opens a text file named “Lab12input.txt†containing multiple lines of text (.txt file has been provided already just need code to open .txt file)
2. for each line, print out “Palindrome:†and then the line of text if it IS a palindrome, and print out “Not a palindrome:†and the line of text if it is NOT a palindrome.
Thanks!
Solution
int checkispallindrome(char* string)
{
int i;
int l = strlen(string);
for (i = 0; i < l / 2; i++)
{
if (string[i] != string[l - i - 1])
cout<<â€not a palindromeâ€;
}
cout<<â€it is a palindromeâ€;
}
int main()
{
FILE* f = fopen(\"myfile.txt\", \"r\");
char string[10];
while(fscanf(f, \"%s\", string) > 0)
{
checkispallindrome(string;
printf(\"%s\ \", string);
}
}
.