Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- char s[100], srev[100];
- gets(s);
- int len, i, j;
- for(i=0, len=0 ; s[i]!=0 ; i++) //determines the Length of the string
- len++;
- for(i=len-1, j=0 ; i>=0 ; i--, j++) //Copies the string
- srev[j]=s[i];
- srev[len]=0;
- puts(srev);
- for(i=0 ; i<len ; i++) //Compares the strings
- if(s[i]!=srev[i])
- break;
- if(i==len && s[i]==0 && srev[i]==0) //final Check
- printf("Palindrome");
- else
- printf("Not Palindrome");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement