Tuesday, 10 October 2017

Java Program Reverse A Number

Java Program Reverse A Number














import java.util.*;
 public class reverse
{
  public static void main(String args[])
{
   Scanner p=new Scanner(System.in);
    int num,rev=0;
       System.out.println("Enter any number please  :");
     num=p.nextInt();
      while(num!=0)
{
     rev=10*rev+(num%10);
      num/=10;
}   System.out.println("The sum of all the elements is :"+rev);
   }}  

0 comments:

Post a Comment