Computer Science, asked by ShreshtaArava, 4 months ago

Write a program to check whether given number is palindrome or not. EX: N= 121, Reverse of N is also 121 so N is Palindrome

Answers

Answered by amithsai62
1

Answer:

Output

121 is a palindrome number

Explanation:

public class Palindrome {

   public static void main(String[] args) {

       int num = 121, reversedInteger = 0, remainder, originalInteger;

       originalInteger = num;

       // reversed integer is stored in variable  

       while( num != 0 )

       {

           remainder = num % 10;

           reversedInteger = reversedInteger * 10 + remainder;

           num  /= 10;

       }

       // palindrome if orignalInteger and reversedInteger are equal

       if (originalInteger == reversedInteger)

           System.out.println(originalInteger + " is a palindrome.");

       else

           System.out.println(originalInteger + " is not a palindrome.");

   }

}

Similar questions