This is a Java program which checks whether a number is palindrome or not .
Generally a number is said to be a palindrome number if its reverse is same as the original number .
For Example : 121 is a palindrome as its reverse is also 121 where as , 231 is not a palindrome as its reverse is 132 .
PROGRAM :
OUTPUT :Generally a number is said to be a palindrome number if its reverse is same as the original number .
For Example : 121 is a palindrome as its reverse is also 121 where as , 231 is not a palindrome as its reverse is 132 .
PROGRAM :
package codingcorner.in;
import java.util.Scanner;
public class Palindrome {
public static void main(String[] args) {
int number, remainder, reverse = 0, num;
Scanner scan = new Scanner(System.in);
System.out.println("Enter a number :\t");
number = scan.nextInt();
scan.close();
num = number;
while (number != 0) {
remainder = number % 10;
reverse = reverse * 10 + remainder;
number = number / 10;
}
if (reverse == num)
System.out.println(num + " is Palindrome");
else
System.out.println(num + " is not a Palindrome");
}
}
Related Programs :
Palindrome number in C
Palindrome number in Cpp
Reverse of a number in Java
Armstrong number in Java
Reverse of a number in C
Reverse Of a number in Cpp
Armstrong number in C
Armstrong number in Cpp
No comments:
Post a Comment