Is Palindrome

Here is why may that happen:

On Windows, line endings are represented with two characters: “\r\n”. “\r” is called carriage return, and “\n” is called line feed. Whenever you are pressing the enter key, you are essentially adding these two characters to the buffer.

On most non-Windows platforms, line endings are represented with just “\n”.

When you use fgets() to read the input, it is actually making “\r” a part of the string.

This is why it is a smarter idea to use scanf("%s", ...) to read strings in C whenever possible. And use fgets when you absolutely need to. You could try it out on Windows and see if that helps.

1 Like

I used scanf("%s",) and this was the final solution. Sorry for disturbing you, and thanks a lot for helping me.

1 Like

This was not disturbing. :slight_smile:

I often ask help from the good programmer guys and all of them get disturbed. Anyway thanks.

printf(“Yes”);
break;
}
else
{
continue;
}
}
else
{
printf(“No”);
break;

use this instead of-
printf(“yes”);
break;
}
else
{
continue;
}
}
else
{
printf(“no”);
break;

please remove accepted codes from everywher. You have already done it couple of times. I might report you next.

sorry bro
I didnt know it works
how I can remove them?
I’ll definitely do this now. sorry again

#include <stdio.h>
#include <string.h>
int main() {
	char p[100];
	scanf ("%c",&p);
	int x=strlen(p);
	int a,b=x-1;
	for (a=0; a<=b; a++,b--){
		if (p[a]==p[b]){
			continue;
			
			
		}
		else if (p[a]!=p[b]){
			break;
		}
	}
	if (a==b+1 || a==b+2){
		printf ("Yes");
	}
	else {
		printf ("No");
	}
	
	return 0;
}

Where is the fault?

#include<stdio.h>
#include<string.h>
int main()
{
    char s[101];
    scanf("%s",&s);
    int len=strlen(s),i,j=0;
    for(i=0;i<=(len-1)/2;i++)
    {
        if(s[i]!=s[len-1-i])
        j=1;
        break;
    }
    if(j!=1)
    {
        printf("Yes");
    }
    else printf("No");
    
}

whats wrong here?

#include
#include <string.h>

using namespace std;

int main()
{
char a[100],b[100];
cin>>a;
strcpy(b,a);
strrev(b);
if(strcmp(a,b)==0)
cout<<“Yes”;
else
cout<<“NO”;

return 0;

}

code is ok but why not accept.

#include <stdio.h>
#include<string.h>
int main() {
	char s[100];
	
	 scanf("%s",s);
	int i,g,k;
    k=strlen(s);
		for(g=k-1,i=0;g>=0,i<=k-1;g--,i++){
			if (s[i]==s[g]){
printf("Yes");
				break ;
				}
else{
	printf("No");
	break;
}
		}
	
	
	
	return 0;
}

what s wrong here??

What is the error?

#include<stdio.h>
int main()
{
    char str1[100],str2[100];
    int count=0,i,j=0;
    printf("\n");
    scanf("%[^\n]",str1);
    
    
    for(i=0;str1[i]!='\0';i++)
        count+=1;
        
    for(i=count-1;i!=-1;i--)
        str2[j++]=str1[i];
        
    str2[j]='\0';
    
    if(str1==str2)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return 0;
}

S = input()
if len(S) % 2 == 0:
for i in range(len(S)):
if S[i-1] == S[-1]:
return Yes

else:
return No

what is my mistake(pls helpsomeone)

in python:
S = input().lower()

w = “”
for i in S:
w = i + w

if (S == w):
print(“Yes”)
else:
print(“No”)

Welcome to Toph Community @wahidpro,

Looks like you have already solved the problem. Good work!

[REDACTED]

the first output is denying. what supposed to be wrong here?

1 Like

Looks like you have solved your problem. It could have been because of using the wrong class name and package declaration.