To Check whether a string is a Palindrome or not using python program
Palindrome
wrd=input("Please enter a word : ")
wrd=str(wrd)
rvs=wrd[::-1]
print(rvs)
if wrd == rvs: print("This word is a palindrome")
else: print("This word is not a palindrome")
/*Program to find the given string is a Palindrome or not */ #include<stdio.h> #include<conio.h> #include<string.h> void main() { char a[15]; int i, len, count=0; clrscr(); printf("\nEnter a string: "); scanf("%s", a); len=strlen(a); for(i=0; i<len; i++) { if(a[i]==a[len-i-1]) count=count+1; } if(count==len) { printf("\nThe given string is a Palindrome"); } else { printf("\nThe given string is not a Palindrome"); } getch(); } OUTPUT: Enter a string: hannah The given string is a Palindrome Enter a string: welcome The given string is not a Palindrome
Comments
Post a Comment