WAP to print the pelendrome 5 digits.

class Palendrome
  {
    public static void main(String args[])
      {
        int n=Integer.parseInt(System.console().readLine("enter the 5 no. digitno. n"));
        int a=n;
        int b=a%10;
        b=b+10000;
        a=a/10;

        int c=a%10;
        c=c+1000;
        a=a/10;

        int d=a%10;
        d=d+100;
        a=a/10;

        int e=a%10;
        e=e+10;
        a=a/10;

        int sum=a+b+c+d+e;
        if(sum==n)
        {
          System.out.println("Entered no. is pelendrome");
        }
        else
        {
          System.out.println("Entered no. is pelendrome");
        }
     }
  }

No comments:

Post a Comment