Programming lang uage is c Implement a recursive function in
Programming lang++ uage is: c
Implement a recursive function
int palindromeCount(string s);
that returns the number of positions in which s is palindromic.
For example palindromeCount(\"abcdefxdcyz\") will return 3 since the c\'s and d\'s match and the f matches itself.
Solution
Code:
#include<stdio.h>
 int main (){
 char str[] = \"abcdefxdcyz\";
 char left, right;
 int len = sizeof(str)-1;
 int count = 0, li = 0, ri = len-1;
 if(len%2 == 1){
    count++;
 }
 int i;
 for(i=0;i<len/2;i++){
    left = str[li];
    right =str[ri];
    if(left == right){
        count++;
    }  
    li++;
    ri--;
 }
 printf(\"Count : %d\ \",count);
 return 0;
 }
Output:

