C programming code :
#include <stdio.h>
#include <string.h>
void isPalindrome(char str[])
{
int l = 0;
int h = strlen(str) - 1;
while (h > l)
{
if (str[l++] != str[h--])
{
printf("No");
return;
}
}
printf("Yes");
}
int main()
{
char s[1000];
scanf("%s",s);
isPalindrome(s);
return 0;
}
Python code:
s = input()
ans = s == s[::-1]
if ans:
print("Yes", end='')
else:
print("No", end='')
Java code:
import java.util.Scanner;
public class code
{
public static void main(String args[])
{
String a, b = "";
Scanner s = new Scanner(System.in);
a = s.nextLine();
int n = a.length();
for(int i = n - 1; i >= 0; i--)
{
b = b + a.charAt(i);
}
if(a.equalsIgnoreCase(b))
{
System.out.print("Yes");
}
else
{
System.out.print("No");
}
}
}
Comments
Post a Comment