Q:

C Program to Check String is a Palindrome or Not

belongs to collection: Array C Programs List

0
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

 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include<stdio.h>
#include<string.h>

void main()
{
  
    printf("=====================================");
    printf("\nerdutella.com");
    printf("\n=====================================");

 while(1)
 {
    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;
            break;
     }
  }
    if (flag)
  {
        printf("\n\n%s Is Not a Palindrome\n", string1);
    }  
    else 
 {
        printf("\n\n%s Is Palindrome\n", string1);
    }
 }
    return 0;
}

 

Output:

=====================================

nerdutella.com

=====================================

Enter a String: malayalam

malayalam Is Palindrome

Enter a String: madam

madam Is Palindrome

Enter a String: yadav

yadav Is Not a Palindrome

Enter a String: 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Program For Convert All Input String Simultaneou... >>
<< C Program For Print \"I AM IDIOT\" Inste...