Q:

Java Program to check the number is palindrome or not?

0

Program to check the number is palindrome or not?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

public class demo1 
{
 public static void main(String[] args) 
 {
 int num[] = new int[]{114,131,24,111,465,54};
 for(int i=0; i < num.length; i++){

 int number = num[i];
 int reversedNumber = 0;
 int a=0;

 while(number > 0){
 a = number % 10;
 number = number / 10;
 reversedNumber = reversedNumber * 10 + a;
 }
 if(num[i] == reversedNumber)
 System.out.println(num[i] + " is a palindrome");
 else
 System.out.println(num[i] + " not a palindrome ");
 }
 }
 }

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now