I used Borland C compiler in this small program. This program is my answer during my test when applying for software engineering job.
#include
#include
/*Start*/
main()
{
char str1[20], str2[20];
clrscr();
printf("Input: "); scanf("%s",&str1);
strcpy(str2,str1);
printf("%s\n",strrev(str2));
if(strcmp(str1,str2)==0) {
printf("String is Palindrome");
}
else
printf("Not Palindrome");
getch();
return 0;
}
/*end*/
There are many styles and ways in making a palindrome, it's up to you how you think or how good you are. Good programmers can make this small code complicated and hard to understand.
Friday, June 20, 2008
Palindrome program in C
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment