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
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
Get step-by-step solutions from verified subject matter experts
