Palindrome Program in C – This program reverses an integer (entered by the user) using while loop. Then, if statement is used to check whether the reversed number is equal to the original number or not. How to check whether a number is palindrome or not in C programming. C program for palindrome numbers. Following are step by step Guide to Check C Palindrome Program.
Input number: 121
Output: 121 is Palindrome
Logic to check palindrome numbers
From the definition of the palindrome numbers it must be clear to all that in-order to check whether a number is palindrome or not we must find the reverse of the number. After retrieving the reverse of number we just need to make a conditional check that whether the given number is equal to its reverse or not. If the given number and its reverse are same then the number is palindrome otherwise not.
Program to check palindrome number
* C program to check whether a number is palindrome or not
int n, num, rev = 0;
/* Reads a number from user */
printf(“Enter any number to check palindrome: “);
num = n; //Copies original value to num.
/* Finds reverse of n and stores in rev */
rev = (rev * 10) + (n % 10);
n = n/10;
/* Check if reverse is equal to original num or not */
printf(“%d is palindrome.”, num);
printf(“%d is not palindrome.”, num);
So, above code is totally free of error you can easily use this for C Palindrome Program – Palindrome Program in C – C Program for Palindrome.