Skip to content
Home » C Programs » Palindrome Program in C For String

Palindrome Program in C For String

Simple 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. By using this method we have executed the palindrome program in c for string.

Palindrome Program in C For String

//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;

Output of Palindrome Program in C For String:

Enter The String
madam is a Palindrome

C Program to Implement abs Function 

C Program to Find Reverse of a String Without Using strrev 

C Program to Generate Prime Numbers upto n 

Newton Raphson Method Program in C Language 

Strong Number in C Using While Loop 

C Program to Implementation of Stack Using Array 

C Program to Calculate Percentage of 5 Subjects 

Dynamic Memory Allocation of Structure in C 

C Program For Power of a Number Using While Loop 

Calculate the Average of Given Numbers in C 

Binary releases – Code::Blocks

GDB online Debugger | Compiler – Code, Compile, Run, Debug online C, C++

Online Compiler and Editor/IDE for Java, C/C++, PHP, Python, Perl, etc

C (programming language)

Applications of C Programming That Will Make You Fall In Love With C