Palindrome Program in C For String

Palindrome program in c for string for beginners to check the string is a palindrome or not in c programming language.

Palindrome Definition

Madam, I’m Adam is an example of a palindrome, which is a word, phrase, or sentence that reads the same backwards and forwards. 

Palindromes, or words that spell other words when spelled backwards, are known as semordnilaps.

Flag Definition in C

A “flag” variable is simply a boolean variable with the value “true” or “false” as its contents. 

You can use a bool variable with true or false values, or an integer variable with zero for “false” and non-zero for “true.” 

A flag is a predefined bit or bit sequence in programming that holds a binary value. 

A flag is typically used by a program to remember something or to leave a message for another program.

Palindrome Program in C For String

#include <stdio.h>
#include <string.h>
int main()
char strarray[20];
int i, length;
int flag = 0;
printf("Enter The String");
scanf("%s", strarray);
length = strlen(strarray);
for(i=0;i < length ;i++)
if(strarray[i] != strarray[length-i-1])
flag = 1;
if (flag) 
printf("%s is Not a Palindrome", strarray);
printf("%s is a Palindrome", strarray);
return 0;


Enter The String
madam is a Palindrome