We can do this by putting the condition if string[start++] is equal to string[ends--] then the string is a palindrome or if this condition fails then the string is not a palindrome. One more thing I want to clarify Palindrome may not only word, Palindrome may be a sentence.
String Palindrome Words Examples
Facts about Malayalam (Southern Indian language) Malayalam is the only language that is Palindrome in both Hindi and English, which means if you write Malayalam in English and Malayalam in Hindi " मलयालम " both are Palindrome.
Palindrome Sentence Example
String Palindrome Words Examples
- Madam
- Civic
- Radar
- Level,
- Rotor
- Mom
- Malayalam
Facts about Malayalam (Southern Indian language) Malayalam is the only language that is Palindrome in both Hindi and English, which means if you write Malayalam in English and Malayalam in Hindi " मलयालम " both are Palindrome.
Palindrome Sentence Example
- Was it a car or a cat I saw
- Murder for a jar of red rum
- King, are you glad you are king
- Yo, banana boy
String Palindrome Program in C Code
#include <stdio.h>
#include <string.h>
/*Write a program to check whether a string is palindrome or not */
void main()
{
while (1)
{
char string1[20];
int i, length;
int flag = 0;
printf("\n\nEnter a String to Check Palindrome String: ");
scanf("%s", string1);
length = strlen(string1);
for (i = 0; i < length; i++)
{
if (string1[i] != string1[length - i - 1])
{
flag = 1;
break;
}
}
if (flag)
{
printf("\n\n%s Is Not a Palindrome String\n", string1);
}
else
{
printf("\n\n%s Is Palindrome String\n", string1);
}
}
return 0;
}
0 Comments: