write a program to check if the given number is a palindrome number
Answers
If like this answer tag to branliest answer
Answer:
import java.util.Scanner ;
public class Palindrome
{
public statis void main (String args[ ] )
{
Scanner sc = new Scanner (System.in) ;
System.out.print("Enter a number to be checked : ") ;
int number = sc.nextInt( ) ;
int reversedNumber = 0, temp = 0, savedNumber ;
savedNumber = number;
do {
temp = number % 10 ;
number = number / 10 ;
reversedNumber = reversedNumber * 10 + temp ;
} while (number! = 0) ;
if ( reversedNumber = = savedNumber)
System.out.println(savedNumber + "is a palindrome") ;
else
System.out.println(savedNumber + "not a palindrome") ;
}
}
Ouput:
Enter a number to be checked : 1221
1221 is a palindrome
Palindrome:
A palindrome reads the same from both sides,
Eg: 1331 is a palindrome number