We are uploading our contents, please refresh app.
Java Premium

Write a program in java to accept a number from the user and check whether it is a Palindrome number or not using do-while loop.

Palindrome number – a number is a Palindrome which when read in reverse order is same as read in the right order. Example: 121, 11, 15451, etc.

Program:
import java.util.*;
class Palin_do_while
{
  public static void main(String args[])
  {
    int n,s=0,r,t;
    Scanner sc=new Scanner(System.in);
    System.out.println("Enter the number to check its a palindrome or not:");
    n=sc.nextInt();
    t=n;
    do
    {
      r=n%10;
      s=(s*10)+r;
      n=n/10;
    }
    while(n!=0);
    if(t==s)
    {
      System.out.println("Entered number is Palindrome");
    }
    else
        System.out.println("Entered number is not Palindrome");
  }
}
Output:
Enter the number to check its a palindrome or not:
121
Entered number is Palindrome

Enter the number to check its a palindrome or not:
12211
Entered number is not Palindrome

Online user

Download our android app Download App Submit your query
x

Get Updates On

Java & Premium Programs

Java Solved & Questions

Java Coding easy to use

Proper Coding

Straight Into Your INBOX!

We are going to send you our resources for free. To collect your copy at first, join our mailing list. We are promising not to bother you by sending useless information. So don't miss any updates, stay connected!