Code Scrappers


Palindrome C program


              #include<stdio.h>
              #include<stdlib.h>

              void main()
              {
                  int n, rem, original;

                  int revno = 0;

                  printf("Enter a number : ");

                  scanf("%d", &n);

                  original = n;

                  while(n)
                  {
                      rem = n%10;

                      revno = revno*10 + rem;

                      n = n / 10;
                  }

                  if (original != revno)
                  {
                      printf("%d is not a palindrome.", original);
                  }

                  else
                  {
                      printf("%d is a palindrome.", original);
                  }
              }
          



Output

    Enter a number : 181

    181 is a palindrome.