Advertisement
Nabil-Ahmed

Untitled

Jul 26th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | None | 0 0
  1. //palindrome//
  2. #include<stdio.h>
  3. int main()
  4. {
  5.     char str1[100], str2[100];
  6.     int i=0, len=0, j,d;
  7.     printf("Enter string : ");
  8.     scanf("%s",&str1);
  9.  
  10.     while(str1[i]!='\0')
  11.     {
  12.         i++;
  13.         len++;
  14.     }
  15.  
  16.     for(j=0,i=len-1;i>=0;i--,j++)
  17.     {
  18.         str2[j]=str1[i];
  19.     }
  20.  
  21.     str2[j]='\0';
  22.  
  23.  
  24.   d=strcmp(str1,str2);
  25.  
  26.   if(d==0)
  27.     {
  28.         printf("This is a palindrome");
  29.     }
  30.     else
  31.     {
  32.         printf("This is not a palindrome");
  33.     }
  34.  
  35.   return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement