Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int main (){
  4. char string [30], temp [30];
  5. int first, last, e;
  6. printf("Enter a string: n");
  7. scanf("%s", &str);
  8.  
  9. for (first=0; str[first]!=''; first++){
  10. e=first;
  11. }
  12. // loop finds the length of the string, e=first is the length of the string
  13.  
  14. for (first=0, first=e; str[first]!='',first>=0, first++, last--){
  15. temp[first]=str[last];
  16. }
  17. temp[first]='';
  18. for (first=0; str[first]!=''; first++){
  19. if(str[first]!=temp[first]){
  20. printf("%s is not a palindrome!"n);
  21. break;
  22. }
  23. if(str[first]==temp[first]){
  24. continue;
  25. }
  26. }
  27. if(str[first]==''){
  28. printf("%s is a palindrome. n");
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement