To find out whether the given Number Palindrome or not.

PHOTO EMBED

Sun Mar 19 2023 04:25:47 GMT+0000 (Coordinated Universal Time)

Saved by @irfan199927 #java

import java.util.Scanner;
//To find out whether the given String is Palindrome or not.  121 , 1331 
public class Main{
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    //input
    int sum = 0;
    int lastdig = 0;
    System.out.println("Enter Your Number");
    int n = in.nextInt();
    int input = n;

    while(n>0){
      lastdig = n%10; //To get the last Dig;
      sum = sum*10+lastdig;
      n = n/10;   //removes last dig from number;
    }
    if(input == sum){
      System.out.println("Number is Palindrome : "+ input + " : " + sum);
    }else{
      System.out.println("Number is Not Palindrome : " + input +" : "+ sum);
    }
    
  } 
}
content_copyCOPY