Posted By:
23 Jun, 2013 1:14 pm PDT

Palindrome in C

How to find whether a number or string is palindrome in C?

To find whether a string is palindrome we first copy that string into a new string and then reverse that string and then compare with the original string. If both strings are same then it is palindrome. To find whether a number is palindrome we reverse the number and then compare with the original. If both are same then it is palindrome. We use the following logic to see if a number is palindrome:

temp = n;

while( temp != 0 )


    reverse = reverse * 10;

    reverse = reverse + temp%10;

    temp = temp/10;



if ( n == reverse )

printf("%d is a palindrome number.\n", n);


printf("%d is not a palindrome number.\n", n);


Please see the video for more details

Was it useful?  

Following is the program for finding out if a string is palindrome or not . 

#include <stdio.h>

#include <string.h>


int main()


   char a[100], b[100];

   printf("Enter the string to check if it is a palindrome\n");





      printf("Entered string is a palindrome.\n");


      printf("Entered string is not a palindrome.\n");




please find attached the program for finding a number is palindrome or not.

Was it useful?  

Please login to reply to this problem.