Where we learn technology

How to check Palindrome Number

How to check Palindrome Number


Learn:
1. check the given number is Palindrome or not.
2. write different test cases



Code:


package Questions;
public class PalindromeNumber {
//151 454 34543 161 78987  
//teet
public static void isPalindromeNumber(int num){
System.out.println(“Given Number is :” + num);
int r=0;
int sum=0;
int t;
t=num;
while(num>0){
r = num%10; //get the remainder
sum = (sum*10)+r;
num=num/10;
}
if(t==sum){
System.out.println(“palindrome number”);
}else{
System.out.println(“not palindrome number”);
}
}
public static void main(String[] args) {
isPalindromeNumber(151);
isPalindromeNumber(152);
isPalindromeNumber(78987);
isPalindromeNumber(1110);
isPalindromeNumber(0);
}
}

Please follow and like us:

5 Comments

  1. Realtekh

    Great post!! This can be one particular of the most useful blogs. Basically Wonderful. I can understand your hard work.

    tasty catering services in chennai
    best caterers in chennai
    catering services in chennai
    tasty catering services in chennai
    party catering services in chennai

Leave a Reply

Your email address will not be published. Required fields are marked *