fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int testPalindrome(const char str[], int start, int end) {
  5. if (start >= end) {
  6. return 1;
  7. }
  8. if (str[start] != str[end]) {
  9. return 0;
  10. }
  11. return testPalindrome(str, start + 1, end - 1);
  12. }
  13.  
  14. int main(void) {
  15. char text[] = "radar";
  16. int len = strlen(text);
  17.  
  18. if (testPalindrome(text, 0, len - 1)) {
  19. printf("It is a palindrome\n");
  20. } else {
  21. printf("It is not a palindrome\n");
  22. }
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0s 5312KB
stdin
Standard input is empty
stdout
It is a palindrome