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); } } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter