package com.swain.cell;
public class Palindrome {
public static void main(String [] args){
try{
int num= 161;
int n = num;
int rev=0;
for (int i=0; i<=num; i++){
int r=num%10;
num=num/10;
rev=rev*10+r;
i=0;
}
if(n == rev){
System.out.print("Number is palindrome!");
}
else{
System.out.println("Number is not palindrome!");
}
}
catch(Exception e){
System.out.println("Error");
}
}
}
No comments:
Post a Comment