Palindrome Program in Java
Palindrome number in java: A palindrome number is a number that is same after reverse. For example 545, 151, 34543, 343, 171, 48984 are the palindrome numbers.
- class PalindromeExample{
- public static void main(String args[]){
- int r,sum=0,temp;
- int n=454;
-
- temp=n;
- while(n>0){
- r=n%10;
- sum=(sum*10)+r;
- n=n/10;
- }
- if(temp==sum)
- System.out.println("palindrome number ");
- else
- System.out.println("not palindrome");
- }
- }
Output:
No comments:
Post a Comment