Palindromes A palindrome is a word or phrase that reads the

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:

1.opens a text file named “Lab12input.txt” containing multiple lines of text

2.for each line, print out the condensed version of that line of text with all non-alphabetic characters removed, and all alphabetic characters turned into lower case.

Write a program that does the following:

1. opens a text file named “Lab12input.txt” containing multiple lines of text (1 or more)

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

#include <stdio.h>

#include <string.h>

int main()

{

char string1[20];

int i, length;

int flag = 0;

printf(\"Enter a string:\");

scanf(\"%s\", string1);

length = strlen(string1);

for(i=0;i < length ;i++)

{ if(string1[i] != string1[length-i-1]){ flag = 1; break;

}

}

if (flag) {

printf(\"%s is not a palindrome\", string1);

}

else {

printf(\"%s is a palindrome\", string1);

} return 0;

}

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. Example
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. Example

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site