PROGRAM FOR PALINDROME NUMBER
import java.io.*;
class palindrome
{
public static void palindrome()throws IOException
{
int r,rev=0;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter the no");
int n=Integer.parseInt(br.readLine());
int no=n;
while(n>0)
{
r=n%10;
rev=rev*10+r;
n=n/10;
}
if(rev == no)
{
System.out.println("the no. is palindrome");
}
else
{
System.out.println("the no is not a palindrome");
}
}
}
import java.io.*;
class palindrome
{
public static void palindrome()throws IOException
{
int r,rev=0;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter the no");
int n=Integer.parseInt(br.readLine());
int no=n;
while(n>0)
{
r=n%10;
rev=rev*10+r;
n=n/10;
}
if(rev == no)
{
System.out.println("the no. is palindrome");
}
else
{
System.out.println("the no is not a palindrome");
}
}
}
No comments:
Post a Comment