Computer Hope

Software => Computer programming => Topic started by: Flux on September 04, 2009, 05:44:17 AM

Title: need help please.... with turbo C
Post 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
Title: Re: need help please.... with turbo C
Post by: Flux on September 04, 2009, 06:10:16 AM
its on Turbo C guys...please need some help
Title: Re: need help please.... with turbo C
Post by: BC_Programmer on September 04, 2009, 08:58:23 AM
what do you have so far? Any ideas on how you'd go about it? (algorithm?)
Title: Re: need help please.... with turbo C
Post by: Salmon Trout on September 04, 2009, 10:15:40 AM
I think the lesson is probably over.
Title: Re: need help please.... with turbo C
Post by: smeezekitty on September 04, 2009, 10:06:09 PM
thats so easy
Code: [Select]
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