Pls help me out with this!

#include<bits/stdc++.h>
using namespace std;

bool pallindrome(char a[1000],int b,int c){

int len=c-b+1;	

for(int k=0;k<len/2;k++){
	if(a[b]!=a[c]){
		return false;
	}
	b++;
	c--;
}

return true;

}

int main() {

char a[1000];
cin>>a;

int i=0;
int j=strlen(a)-1;
int len=strlen(a);
int count=0;

for(i=0;i<=len-1;i++){
	for(int j=i+1;j<len;j++){
		if(pallindrome(a,i,j)) count++;
	}

}

cout<<count;

return 0;

}

hi @anshul3558_e8c9aa486c392ca3, start j with i not i+1

a single character is also considered a pallindrome string? is string “a” pallindrome?

yes @anshul3558_e8c9aa486c392ca3

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.