Write a program to check a number is palindrome or not in java

 Write a program to check a number is palindrome or not in java

public class Palindrome
{
    public static void main(String args[]){
        int num=121,reverse=0,temp;
        temp=num;
        while(temp!=0){
        reverse = 10*reverse+temp%10;
        temp=temp/10;
        }
        
        if(num==reverse){
        System.out.println(num+" is palindrome");
        }else{
        System.out.println(num+" is not palindrome");
        }
    }
}

Output
121 is palindrome

Comments

Popular posts from this blog

Calculate Compound Interest in JavaScript

How to make simple bill maker by using python tkinter

Admin Login Page Using HTML and CSS