write a program to input a number and check whether it is palindrome or not?
plz answer me fast.....!!!!!
Answers
Answer:
import java.util.*;
public class Palindrome
{
public static void main(String args[]){
int num,tNum,sum;
Scanner bf=new Scanner(System.in);
//input an integer number
System.out.print("Enter any integer number: ");
num= bf.nextInt();
//find reverse number
tNum=num;
sum =0;
while(tNum>0)
{
sum = (sum*10) + (tNum%10);
tNum/=10;
}
//check inputted number with reversed number
if(num==sum)
System.out.println(num + " is a Palindrome Number.");
else
System.out.println(num + " is not a Palindrome Number.");
}
}
Explanation:
class palindrome
{
public static void main(int n)
{
int m=n,r,s=0;
for(n!=0;n=n/10)
{
r=n÷10;
s=s+r;
}
if(m==s)
System.out.println("palindrome no.");
else
System. out.println("not a palindrome number");
}
}