Write a program to check number is palindrome or not.
Checking number is palindrome or not using java.
//finding
the palindrome of a given number
import
java.io.*;
public
class palindrome_number
{
public static void
main(String[]args)throws IOException
{
int num,r,s=0,b;
BufferedReader br = new
BufferedReader(new InputStreamReader(System.in));
System.out.println("enter
the number to check palindrome");
num =
Integer.parseInt(br.readLine());
b=num;
while(num>0)
{
r=num%10;
s=(s*10)+r;
num=num/10;
}
if(b==s)
System.out.println("The
number is palindrome");
else
System.out.println("The
number is not palindrome");
}
}
No comments:
Post a Comment