Use this as a template for your program. Since this is only one solution, see if you can come up with another.
Code:
#include <stdio.h>
#include <ctype.h>
int main(void){
char string[1024];
int tag, count, back, flag, loop = 1;
while(loop == 1){
flag = 1;
puts("Enter a word, phrase, or sentence. Or type 'END' to exit:");
for(count = 0; (string[count = getchar()) != '\n'; ++count)
;
if((toupper(string[0]) == 'E') && (toupper(string[1]) == 'N') &&
(toupper(string[2]) == 'D'))
break;
tag = count - 1;
for((count = 0, back = tag); count <= tag/2; (++count, --back)){
if(string[count] != string[back]){
flag = 0;
break;
}
}
for(count = 0; count <= tag; ++count)
putchar(string[count]);
if(flag == 1)
puts(" is a palindrome\n");
else
puts(" is not a palindrome\n");
}
}
-Prelude