Saturday, December 23, 2023

PALINDROME CHECKING

  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                             
  1. kayak
  2. racecar
  3. madam
  4. refer
  5. rotor
  6. deed
  7. noon
  8. tenet
  9. reviver
  10. redder
  11. civic
  12. malayalam
  13. NUMBERS
    1. 1331
    2. 1221
    3. 12321
    4. 454
    5. 909
    6. 1001
    7. 1441
    8. 3443
    9. 2002
    10. 1001
    11. SENTENCE
      1. Able was I ere I saw Elba."
      2. "A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal: Panama!"
      3. "Mr. Owl ate my metal worm."
      4. "Eva, can I see bees in a cave?"
      5. "Madam, in Eden, I'm Adam."
      6. "A Santa at NASA."
      7. "Never a foot too far, even."
      8. "Was it a car or a cat I saw?"
      9. "No lemon, no melon."
      10. "A man, a plan, a canal, analyze the panama canal map."
      11. ALL EXAMPLES REFERANCED BY GOOGLE 💡

No comments:

Post a Comment

DDL command in sql

DATA DEFINITION LANGUAGE DBMS language database language are used to read,update and store data in a database.There are several suc...