C program to check whether the given number is palindrome number or not

Algorithm:

  1. Get the number from keyboard.
  2.  Reverse it.
  3.  Compare it with the number entered by the user.
  4. If both are the same then print palindrome number else print not a palindrome number.
				
					#include <stdio.h>
#include<conio.h>
void main()
{
 int n, reverse = 0, t;
 clrscr();
 printf("Enter a number to check if it is a palindrome or not\n");
 scanf("%d", &n);
 t = n;
 while (t != 0)
 {
  reverse = reverse * 10;
  reverse = reverse + t%10;
  t = t/10;
 }
 if (n == reverse)
 printf("%d is a palindrome number.\n", n);
 else
 printf("%d isn't a palindrome number.\n", n);
 getch();
}
				
			

Leave a Reply