Advertisement
skb50bd

Palindrome

Apr 6th, 2015
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     char s[100], srev[100];
  5.     gets(s);
  6.     int len, i, j;
  7.  
  8.     for(i=0, len=0 ; s[i]!=0 ; i++) //determines the Length of the string
  9.         len++;
  10.     for(i=len-1, j=0 ; i>=0 ; i--, j++) //Copies the string
  11.         srev[j]=s[i];
  12.     srev[len]=0;
  13.     puts(srev);
  14.     for(i=0 ; i<len ; i++) //Compares the strings
  15.         if(s[i]!=srev[i])
  16.             break;
  17.     if(i==len && s[i]==0 && srev[i]==0) //final Check
  18.         printf("Palindrome");
  19.     else
  20.         printf("Not Palindrome");
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement