Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

modify my program so the text in the result prints out the words eg the quick brown fox jumped over the lazy dog,its reverse like

modify my program so the text in the result prints out the words eg the quick brown fox jumped over the lazy dog,its reverse like god yzal eht revo depmuj xof nworb kciuq and that is not a palindrome

#include #include #include #include #include #include #define count 1000 FILE *fileAddress; int isPalindrome(char str[]) { int length,flag = 0, i; length = strlen(str) - 1; // Conver to lowercase string for ( i = 0; i < length; i++) { str[i] = tolower(str[i]); }

for( i=0;i < length ;i++) { // Compare each character from first and last if(str[i] != str[length-i-1]) { // not palindrome flag = 1; } // write reverse string to file fputc(str[length-i-1], fileAddress); } fprintf(fileAddress, " "); if (flag) { // not palindrome return 0; } else { // palindrome return 1; } }

int main() { char s[count]; int n; remove("rs.txt"); fileAddress = fopen("rs.txt", "a"); printf("Just hit enter to start. "); do { while (getchar()!=' '); printf("Enter string: "); fgets(s, count, stdin); n = isPalindrome(s); if(n == 1) { printf(" Yes, %sis a palindrome. ", s); } else { printf(" No, %snot a palindrome ", s); }

printf("Do you still want to continue? "); printf("1=yes, 0= no "); scanf("%d",&n); while(!(n==0 || n==1)) { printf("\a"); scanf("%d",&n); } }while(n==1); fclose(fileAddress); _getch(); return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

Students also viewed these Databases questions

Question

Solve for x: 2(3x 1)2(x + 5) = 12

Answered: 1 week ago