Java Program to reverse any number

Java program to reverse any number 


import java.util.Scanner;
public class ReverseNumber
{
 public static void main(String args[ ])
{
  Scanner s=new Scanner (System.in);
 int n, rem, rev=0;
 System.out.println("Enter any number :");
 n=s.nextInt();

while(n!=0)
{
  rem=n%10;
  rev=(rev*10)+rem;
  n=n/10;
}
  System.out.println("Reverse number is  :"+rev) ; 
    }
 }


Output

Enter any number :223344
Reverse number is  :443322

Comments