Aim:- Write a program in java to check whether the number provided by the user is palindrome or not.
Software used:- Notepad, Command prompt
Program coding:-
public class palindrome
{
public static void main(String[] args)
{
int d,n,rev=0;
n=Integer.parseInt(args[0]);
do
{
d=n%10;
n=(int)n/10;
rev=rev*10+d;
}
while(n>0);
System.out.println(rev);
n=Integer.parseInt(args[0]);
if(n==rev)
System.out.println(n+ " is palindrome");
else
System.out.println(n+ " is not palindrome");
}
}
0 Comments
if you have any problem, please let me know