Java program to check the given number is palindrome or not
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int n,rev=0,r,temp;
Scanner s=new Scanner(System.in);
System.out.println("Enter the number:");
n=s.nextInt();
temp=n;
while (n>0) {
r=n%10;
rev=(rev*10)+r;
n=n/10;
}
if(temp==rev) {
System.out.println("The given number is palindrome");
}
else {
System.out.println("The given number is not palindrome");
}
}
}
Comments
Post a Comment