Translate

Tuesday, June 7, 2016

Write a program to check whether number is palindrome or not in C.

#include<stdio.h>

#include<conio.h>

main()
{
      int n,sum,r,temp;

      sum=0;

      printf("Enter the number which is check palindrome or not=");

      scanf("%d",&n);

      temp=n;

      while(n>0)
      {
                r=n%10;

                sum=(sum*10)+r;

                n=n/10;
                }
                if(temp==sum)
                {
                             printf("the number is palindrome");
                             }
                              else
                             {
                                printf("the number is not palindrome");
                                }
                                getch();
                                }        
               

No comments:

Post a Comment