Computer Science, asked by 5462pikachu, 5 months ago

write a program to check and display whether a given no is a palindrome number or not ( a palindrome number is one which is equal to its reverse example -141)​

Answers

Answered by jeromeseejo73
1

Answer:

import java.util.Scanner;

public class Palindrome  

{

   public static void main(String[] args)  

   {

       int num , reversedInteger = 0, remainder, originalInteger;

       Scanner sc=new Scanner(System.in);

       System.out.print("ENTER A NUMBER: ");

       num=sc.nextInt();

       originalInteger = num;

       //WE ARE FINDING THE FIRST AND THE LAST DIGITS IN THIS while loop

       while( num != 0 )

       {

           remainder = num % 10;

           reversedInteger = reversedInteger * 10 + remainder;

           num  /= 10;

       }

       //Checking whether the first and the last digit is the same and giving appropriate results

       if (originalInteger == reversedInteger)

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

       else

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

   }

}

Explanation:

Similar questions
Math, 2 months ago