CHECK THE CHARACTERS ARE PALINFROME OR NOT
🤔
what palindrome ?
word, number, phrase, or other sequence of symbols that reads the same backwards as forwards.peaples using lots of words in the palindrome without realizing it.: A man, a plan, a canal: Panama! =>is the famous palindrome sentence.
We can find this palindrome in places like in numbers,words,names , sequence ....
Now write a code to find the input is palindrome or not .
-----------------------------------------------------------------------------------------------------------------------------
#include<stdio.h>
#include<string.h>// In this program we use the strlen() function .so we need to include this header file💡
void main()
{
int len,i,count=0,rev=0;
char c[20];
while(rev==0)
{
printf("enter the string \t:");
scanf("%s",&c);
len=strlen(c); // strlen()this function can find the length of the character.{ hai=3}three is the length of the character hai.
printf("total length is:%d\n",len);
for (i=0;i<len;++i)
{
if(c[i]==c[len-i-1])// len-i-1 = ex { len =5, 5-0-1=4, again the loop will decrement the value.
how the looping will pros
{ ex len=5;
printf("palindrome\n"); c[0]==c[4]
c[1]==c[3]
} c[2]==c[2]
else c[3]==c[1]
c[4]==c[0]
{
printf("Not a palindrome\n");
}
}
printf("anything want to check again : 0=NO \t 1=YES\n");
scanf("%d",&rev);
}
}
this string palindrome will take the input value as a array conversion .and check the value from 0th array to last array.2nd array to 2nd from last in this format of checking was perform in there.
__________________________________________________________________________
OUTPUT
enter the string :mom
total length is:3
palindrome
palindrome
palindrome
anything want to check again : 0=NO 1=YES
1
enter the string :malayalam
total length is:9
palindrome
palindrome
palindrome
palindrome
palindrome
palindrome
palindrome
palindrome
palindrome
anything want to check again : 0=NO 1=YES
1
enter the string :good
total length is:4
Not a palindrome
palindrome
palindrome
Not a palindrome
anything want to check again : 0=NO 1=YES
0
-------------------------------------------------------------------------------------------------------------------------
SOME OF THE PALINDROME COLLECTIONS
Words
- kayak
- racecar
- madam
- refer
- rotor
- deed
- noon
- tenet
- reviver
- redder
- civic
- malayalam
- NUMBERS
- 1331
- 1221
- 12321
- 454
- 909
- 1001
- 1441
- 3443
- 2002
- 1001
- SENTENCE
- Able was I ere I saw Elba."
- "A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal: Panama!"
- "Mr. Owl ate my metal worm."
- "Eva, can I see bees in a cave?"
- "Madam, in Eden, I'm Adam."
- "A Santa at NASA."
- "Never a foot too far, even."
- "Was it a car or a cat I saw?"
- "No lemon, no melon."
- "A man, a plan, a canal, analyze the panama canal map."
- ALL EXAMPLES REFERANCED BY GOOGLE 💡
No comments:
Post a Comment