In this program, you'll learn to check whether a number is palindrome or not in Java. This is done by using for and while loop.
Execution Steps
number | number!=0 | remainder | reversedNumber |
131 | true | 1 | 0*10+1 = 1 |
13 | true | 3 | 1*10+3 = 13 |
1 | true | 1 | 13*10+1 = 131 |
0 | false | - | - |
Example:Check Whether a Number is Palindrome or Not
When you run the program, the output will be:
131 is a palindrome.
Post a Comment
Thank you for vising