#include <stdio.h>
#include <conio.h>
void main()
{
int num, temp, digit, rev = 0;
clrscr();
printf(“Enter an integer\n”);
scanf(“%d”, &num);
temp = num; /* original number is stored at temp */
while(num > 0)
{
digit = num % 10;
rev = rev * 10 + digit;
num /= 10;
}
printf(“Given number is = %d\n”, temp);
printf(“Its reverse is = %d\n”, rev);
if(temp == rev )
printf(“Number is a palindrome\n”);
else
printf(“Number is not a palindrome\n”);
}
/*————————
Output
RUN 1
Enter an integer
12321
Given number is = 12321
Its reverse is = 12321
Number is a palindrome
RUN 2
Enter an integer
3456
Given number is = 3456
Its reverse is = 6543
Number is not a palindrome
———————————–*/
Not Satisfied ? Just search & get the result
Related posts:
- C program to check whether a given integer number is positive or negative
- C program to check whether a given integer is odd or even
- C program to find the sum of odd numbers and sum of even numbers from 1 to N. Output the computed sums on two different lines with suitable headings
- Sample – Program to enter an integer and output it in the reversed form.
- Sample – Program to enter an integer and print its total value based on the formula ‘x – 1/3!x3 + 1/5!x5 – 1/7!x7 + 1/9!x9′.
