C program for palindrome number

C program for palindrome number. A palindrome number is a number whose digits, with decimal representation are the same when read from backwards. For example 12321 is a palindromic number as if we again read this number from backward we find same result i.e 12321. This c program is implemented as, first reversing the integer and then comparing the values.
Reversing the integer need to first break the integer into digit. You can find following c program also which breaks the digit and operates :

  • C program to sum the digit of number
  • C program to product the digit of number

C program for palindrome number


#include<stdio.h>
#include<conio.h>

int main()
{
     int no, in = 0, out;
     printf("Enter a number to check if it is a palindrome or not\n");
     scanf("%d",&no);

     out = no;

     while( out != 0 )
     {
          in = in * 10;
          in = in + out%10;
          out = out/10;
     }

     if ( no == in )
     printf("\nIt is a palindrome number.\n");
     else
     printf("\nIt is not a palindrome number.");

     getch();
}

Output of C program for palindrome number:

C program for palindrome number
Output: C program for palindrome number

 


One thought on “C program for palindrome number”

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>