Palindrome Number In Java


 

 

 

Palindrome number in java:

 

 

 

A palindrome number is a number that is same after reverse. For example 545, 151, 34543, 343, 171, 48984 are the palindrome numbers.When we reverse 545 same after reverse 545.

 

 

 

 

 

import java.io.*;

import java.util.*;

class Palindrome

{

public static void main(String args[])

{

System.out.print(“Enter The Number: “);

Scanner read = new Scanner(System.in);

int num = read.nextInt();

int n = num;

//reversing number

int rev=0,rmd;

while(num > 0)

{

rmd = num % 10;

rev = rev * 10 + rmd;

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:

pali

 

 

 

 

 

 

 

 

 

 

 

Palindrome Strings In Java

Related Posts

Comments are closed.