0% found this document useful (0 votes)
74 views2 pages

Check Whether Number Is Palindrome

This Java program checks if a given integer is a palindrome number or not. It takes user input, stores it in a variable n. Another variable re is used to reverse the number. A while loop iterates through the number, extracts the last digit and adds it to re. The original and reversed number are compared, and it prints if the number is palindrome or not.

Uploaded by

swathirohith
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views2 pages

Check Whether Number Is Palindrome

This Java program checks if a given integer is a palindrome number or not. It takes user input, stores it in a variable n. Another variable re is used to reverse the number. A while loop iterates through the number, extracts the last digit and adds it to re. The original and reversed number are compared, and it prints if the number is palindrome or not.

Uploaded by

swathirohith
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Program to check whether a number is palindrome or not import java.io.

*; class palindrome { public static void main(String ar[]) { int n=0,re=0,q; DataInputStream obj= new DataInputStream(System.in); System.out.println("Enter any integer:"); try { n=Integer.parseInt(obj.readLine()); } catch(IOException e) {} q=n; while(q>0) { re=(re*10)+q%10; q=q/10; } if(n==re) System.out.println("No.is palindrome"); else System.out.println("No.is not palindrome"); } } Output:

W3Professors.Com

Ishmeet Singh Dang

W3Professors.Com

Ishmeet Singh Dang

You might also like