Reverse The Number by using Java Program

Code:

import java.util.*;

public class Reverse
{
     public static void main(String[] args)
     {
           int n,i,s=0;

           Scanner sc = new Scanner(System.in);

           System.out.print("\nEnter The Number : ");
           n = sc.nextInt();

           do
           {
                s=s*10+n%10;
                n=n/10;
           }while(n!=0);

           System.out.println("\nThe Reverse Of The Number Is : "+s+"\n");
     }
}

Output of program:


No comments

Powered by Blogger.