Write a program in java to test a number
palindrome or not?
Answers
Explanation:
In this java program, we will get a number variable and check whether number is palindrome or not.
class PalindromeExample{
public static void main(String args[]){
int r,sum=0,temp;
int n=454;//It is the number variable to be checked for palindrome.
temp=n;
while(n>0){
r=n%10; //getting remainder.
sum=(sum*10)+r;
Pls mark as brainlist
Answer:
import java.util.*;
class Palindrome{
public static void main(String args[]){
int r,sum=0,temp;
Scanner s=new Scanner(System.in);
int n=s.nextInt();
temp=n;
while(n>0){
r=n%10; //getting remainder
sum=(sum*10)+r;
n=n/10;
}
if(temp==sum)
System.out.println("palindrome number ");
else
System.out.println("not palindrome");
}
}
Explanation: