Palindrome Program in C language



Write a C program to check or detect given string is Palindrome or not ( Palindrome Program in C ).

palindrome is a word or other sequence of characters which reads the same backward as forward.

Examples of String Palindromes :

madam, wow, racecar, stats, etc.


The program should accept a String as input and check if it is a Palindrome or not.

Here are few example expected input and outputs of program.

Example 1:



The string racecar is palindrome, As we can create the same string in forward direction and backward direction.

Example 2:



Example 3:



Algorithm to Check Palindrome Program :

  • We are going to use two pointer/index method.
  • One index will start from the beginning and goes in the forward direction and another index will starts from the end and comes in backwards direction.
  • Forward index 'i' starts with index and Backward index 'j' starts from 'len-1' ( Here 'len'is the length of the string, So we are starting from the end of the string)
  • At each iteration, We are going to check if the character at index 'i' and the character at index 'j' are same or not?
  • If the string is palindrome then all characters at index 'i' and index 'j' need to be same ( Until ‘i'<‘j’ condition break), If any of the values at index 'i' and index 'j' are not equal then the string is not a Palindrome.
  • If all the characters of 'i' and 'j' are equal until we reach the loop termination i.e ‘i'<‘j’, Then given number is a Palindrome.

Check Palindrome Program in C Language:

Palindrome Program Output:

We are using the GCC compiler on the Ubuntu Linux system. You can use your favourite IDE or Editor.



We have discussed about the logic to detect or check the string palindromes using the C programming Language.

Related Reading:

Related Math Programs:


Hi Guys, I am Venkatesh. I am a programmer and an Open Source enthusiast. I write about programming and technology on this blog.

You may also like...

Leave a Reply