DWQA Ask QuestionCategory: JavaJava_Q: Program to Check if a Number is palindrome
admin Staff asked 5 years ago

//Program to Check if a Number is palindrome

1 Answers
Kulkarni Arundhati answered 5 years ago
Start your code here
import java.util.Scanner;

public class Palindrom {

public static void main(String[] args) {
// TODO Auto-generated method stub
int r,sum=0,temp;
int n;
@SuppressWarnings("resource")
Scanner scan = new Scanner(System.in);
System.out.println("Enter any no: ");
n=scan.nextInt();
temp=n;
while(n>0){
r=n%10;
sum=(sum*10)+r;
n=n/10;
}
if(sum==temp){
System.out.println("No is palindrom : " +sum);
}
else
System.out.println("No is not palindrom : " +temp);
}

}