#include < stdio.h> void main() { int num, temp, remainder, reverse = 0; printf("Enter an integer \n"); scanf("%d", &num); /* original number is stored at temp */ temp = num; while (num > 0) { remainder = num % 10; reverse = reverse * 10 + remainder; num /= 10; } printf("Given number is = %d\n", temp); printf("Its reverse is = %d\n", reverse); if (temp == reverse) printf("Number is a palindrome \n"); else printf("Number is not a palindrome \n"); }
Output
Enter an integer 6789 Given number is = 6789 Its reverse is = 9876 Number is not a palindrome Enter an integer 58085 Given number is = 58085 Its reverse is = 58085 Number i
For More Details Please Visit Ictjobs.info
No comments:
Post a Comment