Java program to reverse number

Java programming source code


  1. class ReverseNumber
  2. {
  3.    public static void main(String args[])
  4.    {
  5.       System.out.println("Enter the number to reverse");
  6.       int n=54321,
  7.       int reverse = 0;

  8.       while( n != 0 )
  9.       {
  10.           reverse = reverse * 10;
  11.           reverse = reverse + n%10;
  12.           n = n/10;
  13.       }

  14.       System.out.println("Reverse number is "+reverse);
  15.    }
  16. }



Output of program:
         Reverse number is 12345

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations