Computer Hope
Software => Computer programming => Topic started by: Flux on September 04, 2009, 05:44:17 AM
-
guys i need help... my teacher wanted us to make a program that gets a name 50 letters and displays it backwards like level=level and prints whether it is a palindrome or not
here it is
create a C program called palindrome(), that will ask the user to enter a word. Then the program will change the word entered in its reverse order. If the Word in reverse form is still the same word, then it is a palindrome, otherwise it is not a palindrome.
sample output:
Enter a Word: Level
level is a palindrome
Enter a Word: Hello
olleh is not a palindrome
-
its on Turbo C guys...please need some help
-
what do you have so far? Any ideas on how you'd go about it? (algorithm?)
-
I think the lesson is probably over.
-
thats so easy
int palindrome(char *input){
char buffer[49],buffer2[49];
strcpy(buffer, input);
strcpy(buffer2, input);
strrev(buffer);
if(strcmp(buffer, buffer2) == 0){return (1);}
return (0);
}
returns 1 if it is a palindrome and 0 if it is not