C Program to check number is a palindrome or not using pointers
In this program, You will learn how to check number is a palindrome or not using pointers in c.
Some list is : 11 22 33 121 131
Example: How to check number is a palindrome or not using pointers in c.
#include<stdio.h>
int main() {
int n, num1, r, rev = 0;
int *num;
printf("Enter a number:");
scanf("%d", &n);
num1 = n;
num = &n;
while (*num > 0) {
r = *num % 10;
rev = rev * 10 + r;
*num = *num / 10;
}
if (rev == num1) {
printf("Number is palindrome:%d", num1);
} else {
printf("Number is not palindrome:%d", num1);
}
return 0;
}
Output:
Enter a number:121
Number is palindrome:121