This is a palindrome number in Java program.
1. Do you know  what is palindrome number?
ans.   Palindrome number is a number which is same after reverse.
as a example : 121 reverse it the result will be 121.
Palindrome number

Go to the series : By clicking java
Palindrome in C : Click here

Source Code:
  1. public class PalindromeNumber {
  2. public static void main(String[] args) {
  3. try (
  4. Scanner input = new Scanner(System.in)) {
  5. int num,temp,sum = 0,r;
  6. System.out.println("Enter the number:");
  7. num = input.nextInt();
  8. temp=num;
  9. while(temp!=0) {
  10. r = temp%10;
  11. sum = sum*10+ r;
  12. temp = temp/10;
  13. }
  14. if(num ==sum) {
  15. System.out.println("This is Palindrome number ");
  16. }
  17. else {
  18. System.out.println("This is not palindrome number.");
  19. }
  20. }
  21. }
  22. }

Output:


Enter the number:
153
This is not palindrome number.

Enter the number:
121
This is Palindrome number 

0 comments:

Post a Comment