Write a program to accept a number and check if it palindrome number Palindrome number is a number whose reverse of a number and original number is same. Example 141
Answers
Answered by
0
Answer:
#include <stdio.h>
int main() {
int n, reversed = 0, remainder, original;
printf("Enter an integer: ");
scanf("%d", &n);
original = n;
// reversed integer is stored in reversed variable
while (n != 0) {
remainder = n % 10;
reversed = reversed * 10 + remainder;
n /= 10;
}
// palindrome if orignal and reversed are equal
if (original == reversed)
printf("%d is a palindrome.", original);
else
printf("%d is not a palindrome.", original);
return 0;
}
Change The Values For Different Results
Thank You ;)
Similar questions