Guest User

Untitled

a guest
Feb 18th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include<stdio.h>
  2. void main()
  3. {
  4. char str[100],rstr[100];
  5. int i,j,lenstr,f=0,k;
  6.  
  7. printf("\nEnter a string \t:");
  8. scanf("%s",str);
  9.  
  10. for(i=0;str[i]!='\0' ;i++);
  11. lenstr=i;
  12.  
  13. for(j=lenstr-1,k=0;j!=-1;j--,k++)
  14. {
  15. rstr[k]=str[j];
  16. }
  17.  
  18. rstr[k]='\0';
  19.  
  20.  
  21. for(i=0,j=0;str[j]!='\0'&&str[j]!='\0';i++,j++)
  22. {
  23. if(rstr[j]!=str[i])
  24. {
  25. f++;
  26. }
  27.  
  28.  
  29. }
  30. if(f!=0)
  31. {
  32. printf("\nString is not Palindrome");
  33. }
  34. else
  35. {
  36. printf("\nString is Palindrome");
  37. }
  38. }
Add Comment
Please, Sign In to add comment