Program to check whether a Number is Palindrome

Program to check whether a Number is Palindrome



Consider the following code in which a number is checked to be palindrome:

CODE:

# include <stdio. h>

# include <conio. h>

void main ()

{

   int a, b, c, s = 0;

   clrscr ();

   printf (“Enter a number:”);

   scanf (“%d”, &a);

   c = a;

   while (a > 0)

   {

      b = a % 10;

      s = (s * 10) + b;

      a = a / 10;

   }

    if (s == c)

   {

      printf (“The number %d is a palindrome”, c);

   }

   else {

      printf (“The number %d is not a palindrome”, c);

   }

  getch ();

}

OUTPUT:

Enter a number 424

The number 424 is palindrome