Palindrome number program in java
Hello friends here we write Palindrome number program in java . Palindrome number is; whenever your reverse number it will be same like original number. Example; 121, 787 etc.
Example of Palindrome number Program in Java
class PalindromeProgram
{
public static void main(String args[])
{
int num, n,rev, rem;
n = num;
reverse=0;
System.out.println("Enter any number: ");
num = Integer.parseInt(args[0]);
while(num > 0)
{
rem = num % 10;
rev = rev * 10 + rem;
num = num / 10;
}
if(rev == n)
System.out.println(n+" is a Palindrome Number");
else
System.out.println(n+" is not a Palindrome Number");
}
}
Output:
Enter any number: 121
121 is a Palindrome Number
No comments :
Post a Comment