What is a Palindrome Number?
A positive integer is said to be a palindrome number or, shortly, a palindrome if
its leftmost digit is the same as its rightmost digit, its second digit from
the left is equal to its second digit from the right, and so on. For example,
33, 142505241, and 6 are palindrome numbers. When we read these numbers from
front and end, it will be the same.
- #include<stdio.h>
- int main()
- {
- int num;
- int r;
- int sum=0;
- int temp;
- printf("Enter number to check palindrome or not\n");
- scanf("%d",&num);
- temp = num;
- while(num>0)
- {
- r = num%10;
- sum = (sum*10)+r;
- num = num/10;
- }
- if(temp == sum)
- printf("Number is palindrome \n");
- else
- printf("Number is NOT palindrome\n");
- return 0;
- }
0 Comments
If you have any doubts, Please let me know