C Program to Check String is a Palindrome or Not

Problem:- C Program to Check whether the Given String is a Palindrome or C Program to Check if a Given String is A Palindrome or C palindrome program or Write a c program to check given string is palindrome number or not or C Program to Check if a String is a Palindrome without using the Built function or C Program/Code to Check whether the given String is Palindrome or not or C Program to Check a String is a Palindrome or Palindrome in C.

Explanation:- String Palindrome in c is simple first we have to know what is palindrome?. According to Wikipedia Palindrome is a word, phrase, or sequence that reads the same backward as forwards, e.g. madam or nurses. so basically in this problem we have to compare the string first index to string last index and second index to second last index one by one and so on. we can do this by putting the condition if string[start++] is equal to string[ends--] then the string is palindrome or if this condition fails then the string is not a palindrome. One more thing I want to clear Palindrome may not only word, Palindrome may me a sentence.

Palindrome Words examples

1. madam
2. nurses
3. Mom
4. Malayalam

Facts about Malayalam (is a south Indian language,) Malayalam is an only language that in Palindrome in both Hindi and English, means if you write Malayalam in English and Malayalam in Hindi " मलयालम " both are Palindrome.

Palindrome Sentence Example

1. Was it a car or a cat I saw
2. Murder for a jar of red rum
3. King, are you glad you are king
4. Yo, banana boy



void main()
/*Visit - www.programmingwithbasics.com*/
    printf("\nVisit - www.programmingwithbasics.com");

    char string1[20];
    int i, length;
    int flag = 0;
    printf("\n\nEnter a String: ");
    scanf("%s", string1);
    length = strlen(string1);
    for(i=0;i < length ;i++)
        if(string1[i] != string1[length-i-1])
            flag = 1;
    if (flag)
        printf("\n\n%s Is Not a Palindrome\n", string1);
        printf("\n\n%s Is Palindrome\n", string1);
    return 0;


C Program to Check String is a Palindrome or Not

You May Also See

1. C Program For Temperature Conversion Celcius To Fahrenheit And Vice Versa Using Switch Case

2. C Program To Find The Day Using Switch Case

3. C Program For Calculator Using Switch Case

4. C Program For Find A Grade Of Given Marks Using Switch Case

No comments:

Post a Comment