//To check no is palindrome or not
import java.util.Scanner;
public class Palindrome {
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter a no:");
int no=sc.nextInt();
if(no<=0)
System.out.println("Can not determine");
else
{
int s=0,n=no;
while(no>0)
{
s=(s*10)+(no%10);
no=no/10;
}
if(n==s)
System.out.println("It is a Palindrome no.");
else
System.out.println("It is not a Palindrome no.");
}
}
}
import java.util.Scanner;
public class Palindrome {
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter a no:");
int no=sc.nextInt();
if(no<=0)
System.out.println("Can not determine");
else
{
int s=0,n=no;
while(no>0)
{
s=(s*10)+(no%10);
no=no/10;
}
if(n==s)
System.out.println("It is a Palindrome no.");
else
System.out.println("It is not a Palindrome no.");
}
}
}
No comments:
Post a Comment