Q.10 Find whether given number is palindrome or not?public class Palindrome {
public static void main(String[] args){
int n=636;
int sum=0,r,temp;
temp=n;
while(n>0){
r=n%10;
sum=(sum*10)+r;
n=n/10;
}
if(temp==sum){
System.out.println(temp+" is a Palindrome");
}
else
System.out.println(temp+" is not a Palindrome");
}
}
No comments:
Post a Comment