fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. int main() {
  4. char text[100];
  5. int begin, middle, end, length = 0;
  6. printf("enter the text:\n");
  7. gets(text);
  8. while ( text[length] != '\0' )
  9. length++;
  10. end = length - 1;
  11. middle = length/2;
  12. for ( begin = 0 ; begin < middle ; begin++ ) {
  13. if ( text[begin] != text[end] ) {
  14. printf("Not a palindrome.\n");
  15. break;
  16. }
  17. end--;
  18. }
  19. if( begin == middle )
  20. printf("%d is Palindrome.\n",text);
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 9432KB
stdin
shashank
raam
stdout
enter the text:
Not a palindrome.