#include<stdio.h>
      #include<conio.h>
      void main()
      {
          int a, b, c, s = 0;
          clrscr();
          printf("Enter a number:\t");
          scanf("%d", &a);
          c = a;
         // the number is reversed inside the while loop.
         while(a > 0)
         {
            b = a%10;
            s = (s*10)+b;
            a = a/10;
         }
         // here the reversed number is compared with the given number.
         if(s == c)
         {
            printf("The number %d is a palindrome", c);
         }
         else
         {
            printf("The number %d is not a palindrome", c);
         }
        getch();
      }
      
      C language logo

      Palindrome

      0

      0

      avatar
      natalie19970

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.