Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!