Article by: Manish Methani
Last Updated: September 27, 2021 at 2:04pm IST
In this article, we are going to cover the following points
Palindrome numbers are referred to as those numbers which give the same number after reversing that number.
For example: Suppose a given number is 1551, then the palindrome number of the given number will be 1551.
2) Palindrome number of 343 will be 343.
Lets write the basic algorithm to check whether the given number is palindrome or not.
Write a program to reverse a number and check whether a given number is palindrome or not.
#include int main() { int i=1551,j; j = i; int n,rem,quo,newnumber=0; for(n=1;n<=4;n++) { rem=i%10; if(n == 4) { newnumber=(newnumber+rem); } else { newnumber=(newnumber+rem)*10; } quo=i/10; i=quo; } printf(" New number = %d",newnumber); printf(" Old number = %d",j); if(j == newnumber) { printf(" Palindrome"); } else { printf(" Not Palindrome"); } }
New number = 1551 Old number = 1551 Palindrome