Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- int isPolindrome(char s[]); //function prototype
- main() {
- char s[20]; int result;
- printf("Enter a string: ");
- gets(s); //scanf("%s",s);
- result = isPolindrome(s); //function call
- if (result == 1)
- printf("polindrome \n");
- else printf("NOT polindrome \n");
- }
- int isPolindrome(char s[]) { //function definition
- int i,j,l,k;
- char rs[20];
- j=0; l= 0; //printf("length = %d \n",l);
- l= strlen(s);
- for(i=l-1;i>=0; i--) { //reversing
- rs[j]=s[i]; j++; }
- rs[j] ='\0'; //printf("The reversed string = %s \n",rs);
- if (strcmp(s,rs) == 0) return (1);
- else return (0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement