Like Us Like Us Facebook Subscribe Subscribe us YouTube Whatsapp Share us Whatsapp Query Send your queries

Java program / script to find palindrome number

Java program / script to find palindrome number

A palindromic number or palindrome number is a number that remains the same when its digits are reversed like

121, 222, 454 ….

Java program to findĀ  palindrome no.

/*
* By Sanjay Prasad
* Check Whether a Number is Palindrome or Not
* A palindrome number is a number such that if we reverse it, it will not change.
*/

import java.util.Scanner;

public class Palindrome{
public static void main(String []args){
int onum, r, sum=0;
System.out.println("Enter a integer");
Scanner keyboard = new Scanner(System.in);
onum= keyboard.nextInt();
int num=onum;

while(num>0){
r=num % 10; //get reminder
sum= sum * 10 + r;
num=num/10;

}

if(onum==sum)
System.out.println("Palindrome");
else
System.out.println("Not a Palindrome");

}
}

palindrome

0 0 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments