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:
- public class PalindromeNumber {
- public static void main(String[] args) {
- try (
- Scanner input = new Scanner(System.in)) {
- int num,temp,sum = 0,r;
- System.out.println("Enter the number:");
- num = input.nextInt();
- temp=num;
- while(temp!=0) {
- r = temp%10;
- sum = sum*10+ r;
- temp = temp/10;
- }
- if(num ==sum) {
- System.out.println("This is Palindrome number ");
- }
- else {
- System.out.println("This is not palindrome number.");
- }
- }
- }
- }
Output:
Enter the number:153This is not palindrome number.Enter the number:121This is Palindrome number
0 comments:
Post a Comment